lib0 0.2.112 → 0.2.115-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 +1 -1
- package/broadcastchannel.js +1 -1
- package/buffer.d.ts +3 -3
- package/buffer.d.ts.map +1 -1
- package/buffer.js +1 -1
- package/coverage/tmp/coverage-27667-1761218530660-0.json +1 -0
- package/coverage/tmp/{coverage-20055-1752683207886-0.json → coverage-27668-1761218485882-0.json} +1 -1
- package/crypto/aes-gcm.d.ts +4 -4
- package/crypto/aes-gcm.d.ts.map +1 -1
- package/crypto/aes-gcm.js +6 -6
- package/crypto/common.d.ts +1 -1
- package/crypto/common.d.ts.map +1 -1
- package/crypto/common.js +1 -1
- package/crypto/ecdsa.d.ts +2 -2
- package/crypto/ecdsa.d.ts.map +1 -1
- package/crypto/ecdsa.js +4 -4
- package/crypto/rsa-oaep.d.ts +2 -2
- package/crypto/rsa-oaep.d.ts.map +1 -1
- package/crypto/rsa-oaep.js +3 -3
- package/decoding.d.ts +27 -14
- package/decoding.d.ts.map +1 -1
- package/decoding.js +12 -8
- package/delta/abstract-array.d.ts +166 -0
- package/delta/abstract-array.d.ts.map +1 -0
- package/delta/abstract-array.js +421 -0
- package/delta/abstract.d.ts +69 -0
- package/delta/abstract.d.ts.map +1 -0
- package/delta/abstract.js +102 -0
- package/delta/array.d.ts +23 -0
- package/delta/array.d.ts.map +1 -0
- package/delta/array.js +45 -0
- package/delta/array.test.d.ts +2 -0
- package/delta/array.test.d.ts.map +1 -0
- package/delta/binding.d.ts +105 -0
- package/delta/binding.d.ts.map +1 -0
- package/delta/binding.js +369 -0
- package/delta/binding.test.d.ts +5 -0
- package/delta/binding.test.d.ts.map +1 -0
- package/delta/d2.d.ts +705 -0
- package/delta/d2.d.ts.map +1 -0
- package/delta/d2.js +1309 -0
- package/delta/d2.test.d.ts +15 -0
- package/delta/d2.test.d.ts.map +1 -0
- package/delta/index.d.ts +14 -0
- package/delta/index.d.ts.map +1 -0
- package/delta/index.js +79 -0
- package/delta/map.d.ts +230 -0
- package/delta/map.d.ts.map +1 -0
- package/delta/map.js +304 -0
- package/delta/node.d.ts +119 -0
- package/delta/node.d.ts.map +1 -0
- package/delta/node.js +183 -0
- package/delta/node.test.d.ts +4 -0
- package/delta/node.test.d.ts.map +1 -0
- package/delta/ops.d.ts +466 -0
- package/delta/ops.d.ts.map +1 -0
- package/delta/ops.js +544 -0
- package/delta/readme.md +129 -0
- package/delta/text.d.ts +43 -0
- package/delta/text.d.ts.map +1 -0
- package/delta/text.js +54 -0
- package/delta/text.test.d.ts +6 -0
- package/delta/text.test.d.ts.map +1 -0
- package/delta/transformer.d.ts +164 -0
- package/delta/transformer.d.ts.map +1 -0
- package/delta/transformer.js +888 -0
- package/delta/transformer.test.d.ts +13 -0
- package/delta/transformer.test.d.ts.map +1 -0
- package/delta/value.d.ts +84 -0
- package/delta/value.d.ts.map +1 -0
- package/delta/value.js +168 -0
- package/dist/abstract-array.cjs +433 -0
- package/dist/abstract-array.cjs.map +1 -0
- package/dist/abstract.cjs +122 -0
- package/dist/abstract.cjs.map +1 -0
- package/dist/aes-gcm.cjs +12 -12
- package/dist/aes-gcm.cjs.map +1 -1
- package/dist/array.cjs +60 -17
- package/dist/array.cjs.map +1 -1
- package/dist/array2.cjs +26 -0
- package/dist/array2.cjs.map +1 -0
- package/dist/binding.cjs +398 -0
- package/dist/binding.cjs.map +1 -0
- package/dist/{broadcastchannel-2c4b0a1c.cjs → broadcastchannel-b4eaea6e.cjs} +4 -4
- package/dist/broadcastchannel-b4eaea6e.cjs.map +1 -0
- package/dist/broadcastchannel.cjs +12 -12
- package/dist/{buffer-a74f7330.cjs → buffer-adc4e6ea.cjs} +7 -7
- package/dist/buffer-adc4e6ea.cjs.map +1 -0
- package/dist/buffer.cjs +11 -11
- package/dist/buffer.d.ts +3 -3
- package/dist/buffer.d.ts.map +1 -1
- package/dist/cache.cjs +6 -6
- package/dist/common.cjs +1 -1
- package/dist/common.cjs.map +1 -1
- package/dist/component.cjs +14 -9
- package/dist/component.cjs.map +1 -1
- package/dist/crypto/aes-gcm.d.ts +4 -4
- package/dist/crypto/aes-gcm.d.ts.map +1 -1
- package/dist/crypto/common.d.ts +1 -1
- package/dist/crypto/common.d.ts.map +1 -1
- package/dist/crypto/ecdsa.d.ts +2 -2
- package/dist/crypto/ecdsa.d.ts.map +1 -1
- package/dist/crypto/rsa-oaep.d.ts +2 -2
- package/dist/crypto/rsa-oaep.d.ts.map +1 -1
- package/dist/d2.cjs +1347 -0
- package/dist/d2.cjs.map +1 -0
- package/dist/{decoding-2b136346.cjs → decoding-50b9ce38.cjs} +18 -14
- package/dist/decoding-50b9ce38.cjs.map +1 -0
- package/dist/decoding.cjs +6 -6
- package/dist/decoding.d.ts +27 -14
- package/dist/decoding.d.ts.map +1 -1
- package/dist/delta/abstract-array.d.ts +166 -0
- package/dist/delta/abstract-array.d.ts.map +1 -0
- package/dist/delta/abstract.d.ts +69 -0
- package/dist/delta/abstract.d.ts.map +1 -0
- package/dist/delta/array.d.ts +23 -0
- package/dist/delta/array.d.ts.map +1 -0
- package/dist/delta/array.test.d.ts +2 -0
- package/dist/delta/array.test.d.ts.map +1 -0
- package/dist/delta/binding.d.ts +105 -0
- package/dist/delta/binding.d.ts.map +1 -0
- package/dist/delta/binding.test.d.ts +5 -0
- package/dist/delta/binding.test.d.ts.map +1 -0
- package/dist/delta/d2.d.ts +705 -0
- package/dist/delta/d2.d.ts.map +1 -0
- package/dist/delta/d2.test.d.ts +15 -0
- package/dist/delta/d2.test.d.ts.map +1 -0
- package/dist/delta/index.d.ts +14 -0
- package/dist/delta/index.d.ts.map +1 -0
- package/dist/delta/map.d.ts +230 -0
- package/dist/delta/map.d.ts.map +1 -0
- package/dist/delta/node.d.ts +119 -0
- package/dist/delta/node.d.ts.map +1 -0
- package/dist/delta/node.test.d.ts +4 -0
- package/dist/delta/node.test.d.ts.map +1 -0
- package/dist/delta/ops.d.ts +466 -0
- package/dist/delta/ops.d.ts.map +1 -0
- package/dist/delta/text.d.ts +43 -0
- package/dist/delta/text.d.ts.map +1 -0
- package/dist/delta/text.test.d.ts +6 -0
- package/dist/delta/text.test.d.ts.map +1 -0
- package/dist/delta/transformer.d.ts +164 -0
- package/dist/delta/transformer.d.ts.map +1 -0
- package/dist/delta/transformer.test.d.ts +13 -0
- package/dist/delta/transformer.test.d.ts.map +1 -0
- package/dist/delta/value.d.ts +84 -0
- package/dist/delta/value.d.ts.map +1 -0
- package/dist/{diff-77c4cf8e.cjs → diff-f0776c15.cjs} +2 -2
- package/dist/{diff-77c4cf8e.cjs.map → diff-f0776c15.cjs.map} +1 -1
- package/dist/diff.cjs +3 -3
- package/dist/{dom-16daf1a0.cjs → dom-2b123630.cjs} +31 -2
- package/dist/dom-2b123630.cjs.map +1 -0
- package/dist/dom.cjs +17 -2
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.ts +17 -0
- package/dist/dom.d.ts.map +1 -1
- package/dist/ecdsa.cjs +4 -4
- package/dist/ecdsa.cjs.map +1 -1
- package/dist/{encoding-1acb59c4.cjs → encoding-7f85922c.cjs} +5 -5
- package/dist/encoding-7f85922c.cjs.map +1 -0
- package/dist/encoding.cjs +4 -4
- package/dist/encoding.d.ts +6 -6
- package/dist/encoding.d.ts.map +1 -1
- package/dist/{environment-2de08e0e.cjs → environment-90227ead.cjs} +4 -4
- package/dist/{environment-2de08e0e.cjs.map → environment-90227ead.cjs.map} +1 -1
- package/dist/environment.cjs +5 -5
- package/dist/{error-8582d695.cjs → error-0c1f634f.cjs} +10 -2
- package/dist/error-0c1f634f.cjs.map +1 -0
- package/dist/error.cjs +2 -1
- package/dist/error.cjs.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/{eventloop-b299a889.cjs → eventloop-a0168106.cjs} +2 -2
- package/dist/{eventloop-b299a889.cjs.map → eventloop-a0168106.cjs.map} +1 -1
- package/dist/eventloop.cjs +3 -3
- package/dist/{function-09b8292c.cjs → function-e7d18feb.cjs} +2 -2
- package/dist/{function-09b8292c.cjs.map → function-e7d18feb.cjs.map} +1 -1
- package/dist/function.cjs +2 -2
- package/dist/index.cjs +23 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index2.cjs +71 -0
- package/dist/index2.cjs.map +1 -0
- package/dist/{indexeddb-0cbb4d6f.cjs → indexeddb-46d1e737.cjs} +3 -3
- package/dist/{indexeddb-0cbb4d6f.cjs.map → indexeddb-46d1e737.cjs.map} +1 -1
- package/dist/indexeddb.cjs +5 -5
- package/dist/indexeddbV2.cjs +2 -1
- package/dist/indexeddbV2.cjs.map +1 -1
- package/dist/jwt.cjs +12 -12
- package/dist/list.cjs +39 -12
- package/dist/list.cjs.map +1 -1
- package/dist/list.d.ts +13 -3
- package/dist/list.d.ts.map +1 -1
- package/dist/logging.cjs +11 -9
- package/dist/logging.cjs.map +1 -1
- package/dist/logging.common.cjs +7 -7
- package/dist/logging.node.cjs +7 -7
- package/dist/{map-0dabcc55.cjs → map-24d263c0.cjs} +7 -1
- package/dist/map-24d263c0.cjs.map +1 -0
- package/dist/map.cjs +314 -7
- package/dist/map.cjs.map +1 -1
- package/dist/map.d.ts +1 -0
- package/dist/map.d.ts.map +1 -1
- package/dist/map2.cjs +15 -0
- package/dist/map2.cjs.map +1 -0
- package/dist/{math-08e068f9.cjs → math-96d5e8c4.cjs} +4 -2
- package/dist/math-96d5e8c4.cjs.map +1 -0
- package/dist/math.cjs +1 -1
- package/dist/math.d.ts.map +1 -1
- package/dist/metric.cjs +1 -1
- package/dist/node.cjs +206 -0
- package/dist/node.cjs.map +1 -0
- package/dist/{number-466d8922.cjs → number-1fb57bba.cjs} +2 -2
- package/dist/{number-466d8922.cjs.map → number-1fb57bba.cjs.map} +1 -1
- package/dist/number.cjs +2 -2
- package/dist/{object-491858d1.cjs → object-18980796.cjs} +12 -2
- package/dist/object-18980796.cjs.map +1 -0
- package/dist/object.cjs +3 -1
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.ts +3 -0
- package/dist/object.d.ts.map +1 -1
- package/dist/observable.cjs +1 -1
- package/dist/ops.cjs +575 -0
- package/dist/ops.cjs.map +1 -0
- package/dist/patience.cjs +2 -2
- package/dist/performance.node.cjs +4 -4
- package/dist/pledge.cjs +2 -1
- package/dist/pledge.cjs.map +1 -1
- package/dist/{prng-24dfe0bf.cjs → prng-004c76e8.cjs} +5 -5
- package/dist/{prng-24dfe0bf.cjs.map → prng-004c76e8.cjs.map} +1 -1
- package/dist/prng.cjs +12 -12
- package/dist/prng.d.ts +1 -1
- package/dist/prng.d.ts.map +1 -1
- package/dist/{promise-7d13a97c.cjs → promise-cda7b9bb.cjs} +2 -2
- package/dist/{promise-7d13a97c.cjs.map → promise-cda7b9bb.cjs.map} +1 -1
- package/dist/promise.cjs +3 -3
- package/dist/rabin-gf2-polynomial.cjs +11 -11
- package/dist/rabin-uncached.cjs +11 -11
- package/dist/rabin.cjs +11 -11
- package/dist/random.cjs +1 -1
- package/dist/rsa-oaep.cjs +3 -3
- package/dist/rsa-oaep.cjs.map +1 -1
- package/dist/schema.cjs +572 -167
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +326 -122
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.test.d.ts +5 -0
- package/dist/schema.test.d.ts.map +1 -1
- package/dist/{sort-b8702761.cjs → sort-812cc211.cjs} +2 -2
- package/dist/{sort-b8702761.cjs.map → sort-812cc211.cjs.map} +1 -1
- package/dist/sort.cjs +2 -2
- package/dist/{statistics-c2316dca.cjs → statistics-65f6114b.cjs} +2 -2
- package/dist/{statistics-c2316dca.cjs.map → statistics-65f6114b.cjs.map} +1 -1
- package/dist/statistics.cjs +2 -2
- package/dist/{string-b2827a90.cjs → string-fddc5f8b.cjs} +3 -3
- package/dist/string-fddc5f8b.cjs.map +1 -0
- package/dist/string.cjs +1 -1
- package/dist/string.d.ts +3 -3
- package/dist/string.d.ts.map +1 -1
- package/dist/testing.cjs +16 -16
- package/dist/text.cjs +79 -0
- package/dist/text.cjs.map +1 -0
- package/dist/{time-bc2081b9.cjs → time-d8438852.cjs} +2 -2
- package/dist/{time-bc2081b9.cjs.map → time-d8438852.cjs.map} +1 -1
- package/dist/time.cjs +2 -2
- package/dist/traits.cjs +22 -0
- package/dist/traits.cjs.map +1 -1
- package/dist/traits.d.ts +1 -0
- package/dist/traits.d.ts.map +1 -1
- package/dist/traits.test.d.ts.map +1 -1
- package/dist/transformer.cjs +930 -0
- package/dist/transformer.cjs.map +1 -0
- package/dist/url.cjs +2 -1
- package/dist/url.cjs.map +1 -1
- package/dist/value.cjs +187 -0
- package/dist/value.cjs.map +1 -0
- package/dist/webcrypto.d.ts +1 -1
- package/dist/webcrypto.d.ts.map +1 -1
- package/dist/{websocket-40a601d4.cjs → websocket-b073d0fc.cjs} +3 -3
- package/dist/{websocket-40a601d4.cjs.map → websocket-b073d0fc.cjs.map} +1 -1
- package/dist/websocket.cjs +4 -4
- package/dom.d.ts +17 -0
- package/dom.d.ts.map +1 -1
- package/dom.js +21 -0
- package/encoding.d.ts +6 -6
- package/encoding.d.ts.map +1 -1
- package/encoding.js +1 -1
- package/error.d.ts +1 -0
- package/error.d.ts.map +1 -1
- package/error.js +6 -0
- package/list.d.ts +13 -3
- package/list.d.ts.map +1 -1
- package/list.js +36 -8
- package/map.d.ts +1 -0
- package/map.d.ts.map +1 -1
- package/map.js +6 -0
- package/math.d.ts.map +1 -1
- package/math.js +3 -1
- package/object.d.ts +3 -0
- package/object.d.ts.map +1 -1
- package/object.js +9 -1
- package/package.json +9 -3
- package/prng.d.ts +1 -1
- package/prng.d.ts.map +1 -1
- package/prng.js +1 -1
- package/schema.d.ts +326 -122
- package/schema.d.ts.map +1 -1
- package/schema.js +513 -141
- package/schema.test.d.ts +5 -0
- package/schema.test.d.ts.map +1 -1
- package/string.d.ts +3 -3
- package/string.d.ts.map +1 -1
- package/string.js +2 -2
- package/test.html +1 -0
- package/test.js +13 -1
- package/traits.d.ts +1 -0
- package/traits.d.ts.map +1 -1
- package/traits.js +21 -0
- package/traits.test.d.ts.map +1 -1
- package/webcrypto.d.ts +1 -1
- package/webcrypto.d.ts.map +1 -1
- package/coverage/tmp/coverage-20054-1752683240888-0.json +0 -1
- package/dist/broadcastchannel-2c4b0a1c.cjs.map +0 -1
- package/dist/buffer-a74f7330.cjs.map +0 -1
- package/dist/decoding-2b136346.cjs.map +0 -1
- package/dist/dom-16daf1a0.cjs.map +0 -1
- package/dist/encoding-1acb59c4.cjs.map +0 -1
- package/dist/error-8582d695.cjs.map +0 -1
- package/dist/map-0dabcc55.cjs.map +0 -1
- package/dist/math-08e068f9.cjs.map +0 -1
- package/dist/object-491858d1.cjs.map +0 -1
- package/dist/string-b2827a90.cjs.map +0 -1
package/dist/schema.cjs
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var object
|
|
6
|
-
var array
|
|
7
|
-
var error = require('./error-
|
|
8
|
-
var environment = require('./environment-
|
|
5
|
+
var object = require('./object-18980796.cjs');
|
|
6
|
+
var array = require('./array-78849c95.cjs');
|
|
7
|
+
var error = require('./error-0c1f634f.cjs');
|
|
8
|
+
var environment = require('./environment-90227ead.cjs');
|
|
9
|
+
var traits = require('./traits.cjs');
|
|
10
|
+
var _function = require('./function-e7d18feb.cjs');
|
|
11
|
+
var string = require('./string-fddc5f8b.cjs');
|
|
9
12
|
require('./set-5b47859e.cjs');
|
|
10
|
-
require('./map-
|
|
11
|
-
require('./string-b2827a90.cjs');
|
|
13
|
+
require('./map-24d263c0.cjs');
|
|
12
14
|
require('./conditions-f5c0c102.cjs');
|
|
13
15
|
require('./storage.cjs');
|
|
14
|
-
require('./function-09b8292c.cjs');
|
|
15
|
-
require('./traits.cjs');
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @experimental WIP
|
|
@@ -30,17 +30,22 @@ require('./traits.cjs');
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* @template T
|
|
33
|
-
* @typedef {T extends
|
|
33
|
+
* @typedef {T extends Schema<infer X> ? X : T} Unwrap
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @template T
|
|
38
|
+
* @typedef {T extends Schema<infer X> ? X : T} TypeOf
|
|
34
39
|
*/
|
|
35
40
|
|
|
36
41
|
/**
|
|
37
42
|
* @template {readonly unknown[]} T
|
|
38
|
-
* @typedef {T extends readonly [
|
|
43
|
+
* @typedef {T extends readonly [Schema<infer First>, ...infer Rest] ? [First, ...UnwrapArray<Rest>] : [] } UnwrapArray
|
|
39
44
|
*/
|
|
40
45
|
|
|
41
46
|
/**
|
|
42
47
|
* @template T
|
|
43
|
-
* @typedef {T extends
|
|
48
|
+
* @typedef {T extends Schema<infer S> ? Schema<S> : never} CastToSchema
|
|
44
49
|
*/
|
|
45
50
|
|
|
46
51
|
/**
|
|
@@ -67,11 +72,98 @@ require('./traits.cjs');
|
|
|
67
72
|
|
|
68
73
|
const schemaSymbol = Symbol('0schema');
|
|
69
74
|
|
|
75
|
+
class ValidationError {
|
|
76
|
+
constructor () {
|
|
77
|
+
/**
|
|
78
|
+
* Reverse errors
|
|
79
|
+
* @type {Array<{ path: string?, expected: string, has: string, message: string? }>}
|
|
80
|
+
*/
|
|
81
|
+
this._rerrs = [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {string?} path
|
|
86
|
+
* @param {string} expected
|
|
87
|
+
* @param {string} has
|
|
88
|
+
* @param {string?} message
|
|
89
|
+
*/
|
|
90
|
+
extend (path, expected, has, message = null) {
|
|
91
|
+
this._rerrs.push({ path, expected, has, message });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
toString () {
|
|
95
|
+
const s = [];
|
|
96
|
+
for (let i = this._rerrs.length - 1; i > 0; i--) {
|
|
97
|
+
const r = this._rerrs[i];
|
|
98
|
+
s.push(string.repeat(' ', (this._rerrs.length - i) * 2) + `${r.path != null ? `[${r.path}] ` : ''}${r.has} doesn't match ${r.expected}. ${r.message}`);
|
|
99
|
+
}
|
|
100
|
+
return s.join('\n')
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param {any} a
|
|
106
|
+
* @param {any} b
|
|
107
|
+
* @return {boolean}
|
|
108
|
+
*/
|
|
109
|
+
const shapeExtends = (a, b) => {
|
|
110
|
+
if (a === b) return true
|
|
111
|
+
if (a == null || b == null || a.constructor !== b.constructor) return false
|
|
112
|
+
if (a[traits.EqualityTraitSymbol]) return traits.equals(a, b) // last resort: check equality (do this before array and obj check which don't implement the equality trait)
|
|
113
|
+
if (array.isArray(a)) {
|
|
114
|
+
return array.every(a, aitem =>
|
|
115
|
+
array.some(b, bitem => shapeExtends(aitem, bitem))
|
|
116
|
+
)
|
|
117
|
+
} else if (object.isObject(a)) {
|
|
118
|
+
return object.every(a, (aitem, akey) =>
|
|
119
|
+
shapeExtends(aitem, b[akey])
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
/* c8 ignore next */
|
|
123
|
+
return false
|
|
124
|
+
};
|
|
125
|
+
|
|
70
126
|
/**
|
|
71
127
|
* @template T
|
|
128
|
+
* @implements {traits.EqualityTrait}
|
|
72
129
|
*/
|
|
73
|
-
class
|
|
74
|
-
|
|
130
|
+
class Schema {
|
|
131
|
+
// this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore
|
|
132
|
+
/**
|
|
133
|
+
* If true, the more things are added to the shape the more objects this schema will accept (e.g.
|
|
134
|
+
* union). By default, the more objects are added, the the fewer objects this schema will accept.
|
|
135
|
+
* @protected
|
|
136
|
+
*/
|
|
137
|
+
static _dilutes = false
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @param {Schema<any>} other
|
|
141
|
+
*/
|
|
142
|
+
extends (other) {
|
|
143
|
+
let [a, b] = [/** @type {any} */(this).shape, /** @type {any} */ (other).shape];
|
|
144
|
+
if (/** @type {typeof Schema<any>} */ (this.constructor)._dilutes) [b, a] = [a, b];
|
|
145
|
+
return shapeExtends(a, b)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Overwrite this when necessary. By default, we only check the `shape` property which every shape
|
|
150
|
+
* should have.
|
|
151
|
+
* @param {Schema<any>} other
|
|
152
|
+
*/
|
|
153
|
+
equals (other) {
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
return this.constructor === other.constructor && _function.equalityDeep(this.shape, other.shape)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
[schemaSymbol] () { return true }
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param {object} other
|
|
162
|
+
*/
|
|
163
|
+
[traits.EqualityTraitSymbol] (other) {
|
|
164
|
+
return this.equals(/** @type {any} */ (other))
|
|
165
|
+
}
|
|
166
|
+
|
|
75
167
|
/**
|
|
76
168
|
* Use `schema.validate(obj)` with a typed parameter that is already of typed to be an instance of
|
|
77
169
|
* Schema. Validate will check the structure of the parameter and return true iff the instance
|
|
@@ -89,25 +181,26 @@ class $Schema {
|
|
|
89
181
|
* Similar to validate, but this method accepts untyped parameters.
|
|
90
182
|
*
|
|
91
183
|
* @param {any} _o
|
|
184
|
+
* @param {ValidationError} [_err]
|
|
92
185
|
* @return {_o is T}
|
|
93
186
|
*/
|
|
94
|
-
check (_o) {
|
|
187
|
+
check (_o, _err) {
|
|
95
188
|
error.methodUnimplemented();
|
|
96
189
|
}
|
|
97
190
|
/* c8 ignore stop */
|
|
98
191
|
|
|
99
192
|
/**
|
|
100
|
-
* @type {
|
|
193
|
+
* @type {Schema<T?>}
|
|
101
194
|
*/
|
|
102
195
|
get nullable () {
|
|
103
|
-
return union(this,
|
|
196
|
+
return $union(this, $null)
|
|
104
197
|
}
|
|
105
198
|
|
|
106
199
|
/**
|
|
107
|
-
* @type {$Optional
|
|
200
|
+
* @type {$Optional<Schema<T>>}
|
|
108
201
|
*/
|
|
109
202
|
get optional () {
|
|
110
|
-
return new $Optional(/** @type {
|
|
203
|
+
return new $Optional(/** @type {Schema<T>} */ (this))
|
|
111
204
|
}
|
|
112
205
|
|
|
113
206
|
/**
|
|
@@ -118,20 +211,27 @@ class $Schema {
|
|
|
118
211
|
* **Do not rely on these error messages!**
|
|
119
212
|
* Performs an assertion check only if not in a production environment.
|
|
120
213
|
*
|
|
121
|
-
* @
|
|
122
|
-
* @
|
|
214
|
+
* @template OO
|
|
215
|
+
* @param {OO} o
|
|
216
|
+
* @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)}
|
|
123
217
|
*/
|
|
124
218
|
cast (o) {
|
|
125
219
|
assert(o, this);
|
|
126
|
-
return o
|
|
220
|
+
return /** @type {any} */ (o)
|
|
127
221
|
}
|
|
128
222
|
|
|
129
223
|
/**
|
|
224
|
+
* EXPECTO PATRONUM!! 🪄
|
|
225
|
+
* This function protects against type errors. Though it may not work in the real world.
|
|
226
|
+
*
|
|
227
|
+
* "After all this time?"
|
|
228
|
+
* "Always." - Snape, talking about type safety
|
|
229
|
+
*
|
|
130
230
|
* Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed.
|
|
131
231
|
* Use this if you know that the type is of a specific type and you just want to convince the type
|
|
132
232
|
* system.
|
|
133
233
|
*
|
|
134
|
-
* Can be useful when defining lambdas: `s.lambda(s.$number, s.$void).
|
|
234
|
+
* Can be useful when defining lambdas: `s.lambda(s.$number, s.$void).expect((n) => n + 1)`
|
|
135
235
|
*
|
|
136
236
|
* **Do not rely on these error messages!**
|
|
137
237
|
* Performs an assertion check if not in a production environment.
|
|
@@ -139,60 +239,115 @@ class $Schema {
|
|
|
139
239
|
* @param {T} o
|
|
140
240
|
* @return {o extends T ? T : never}
|
|
141
241
|
*/
|
|
142
|
-
|
|
242
|
+
expect (o) {
|
|
143
243
|
assert(o, this);
|
|
144
244
|
return o
|
|
145
245
|
}
|
|
146
246
|
}
|
|
147
247
|
|
|
248
|
+
/**
|
|
249
|
+
* @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} Constr
|
|
250
|
+
* @typedef {Constr extends ((...args:any[]) => infer T) ? T : (Constr extends (new (...args:any[]) => any) ? InstanceType<Constr> : never)} Instance
|
|
251
|
+
*/
|
|
252
|
+
|
|
148
253
|
/**
|
|
149
254
|
* @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} C
|
|
150
|
-
* @extends {
|
|
255
|
+
* @extends {Schema<Instance<C>>}
|
|
151
256
|
*/
|
|
152
|
-
class $ConstructedBy extends
|
|
257
|
+
class $ConstructedBy extends Schema {
|
|
153
258
|
/**
|
|
154
259
|
* @param {C} c
|
|
260
|
+
* @param {((o:Instance<C>)=>boolean)|null} check
|
|
155
261
|
*/
|
|
156
|
-
constructor (c) {
|
|
262
|
+
constructor (c, check) {
|
|
157
263
|
super();
|
|
158
|
-
this.
|
|
264
|
+
this.shape = c;
|
|
265
|
+
this._c = check;
|
|
159
266
|
}
|
|
160
267
|
|
|
161
268
|
/**
|
|
162
269
|
* @param {any} o
|
|
270
|
+
* @param {ValidationError} [err]
|
|
163
271
|
* @return {o is C extends ((...args:any[]) => infer T) ? T : (C extends (new (...args:any[]) => any) ? InstanceType<C> : never)} o
|
|
164
272
|
*/
|
|
165
|
-
check (o) {
|
|
166
|
-
|
|
273
|
+
check (o, err = undefined) {
|
|
274
|
+
const c = o?.constructor === this.shape && (this._c == null || this._c(o));
|
|
275
|
+
/* c8 ignore next */
|
|
276
|
+
!c && err?.extend(null, this.shape.name, o?.constructor.name, o?.constructor !== this.shape ? 'Constructor match failed' : 'Check failed');
|
|
277
|
+
return c
|
|
167
278
|
}
|
|
168
279
|
}
|
|
169
280
|
|
|
170
281
|
/**
|
|
171
282
|
* @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} C
|
|
172
283
|
* @param {C} c
|
|
284
|
+
* @param {((o:Instance<C>) => boolean)|null} check
|
|
173
285
|
* @return {CastToSchema<$ConstructedBy<C>>}
|
|
174
286
|
*/
|
|
175
|
-
const constructedBy = c => new $ConstructedBy(c);
|
|
287
|
+
const $constructedBy = (c, check = null) => new $ConstructedBy(c, check);
|
|
288
|
+
const $$constructedBy = $constructedBy($ConstructedBy);
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Check custom properties on any object. You may want to overwrite the generated Schema<any>.
|
|
292
|
+
*
|
|
293
|
+
* @extends {Schema<any>}
|
|
294
|
+
*/
|
|
295
|
+
class $Custom extends Schema {
|
|
296
|
+
/**
|
|
297
|
+
* @param {(o:any) => boolean} check
|
|
298
|
+
*/
|
|
299
|
+
constructor (check) {
|
|
300
|
+
super();
|
|
301
|
+
/**
|
|
302
|
+
* @type {(o:any) => boolean}
|
|
303
|
+
*/
|
|
304
|
+
this.shape = check;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @param {any} o
|
|
309
|
+
* @param {ValidationError} err
|
|
310
|
+
* @return {o is any}
|
|
311
|
+
*/
|
|
312
|
+
check (o, err) {
|
|
313
|
+
const c = this.shape(o);
|
|
314
|
+
/* c8 ignore next */
|
|
315
|
+
!c && err?.extend(null, 'custom prop', o?.constructor.name, 'failed to check custom prop');
|
|
316
|
+
return c
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @param {(o:any) => boolean} check
|
|
322
|
+
* @return {Schema<any>}
|
|
323
|
+
*/
|
|
324
|
+
const $custom = check => new $Custom(check);
|
|
325
|
+
const $$custom = $constructedBy($Custom);
|
|
176
326
|
|
|
177
327
|
/**
|
|
178
328
|
* @template {LiteralType} T
|
|
179
|
-
* @extends {
|
|
329
|
+
* @extends {Schema<T>}
|
|
180
330
|
*/
|
|
181
|
-
class $Literal extends
|
|
331
|
+
class $Literal extends Schema {
|
|
182
332
|
/**
|
|
183
333
|
* @param {Array<T>} literals
|
|
184
334
|
*/
|
|
185
335
|
constructor (literals) {
|
|
186
336
|
super();
|
|
187
|
-
this.
|
|
337
|
+
this.shape = literals;
|
|
188
338
|
}
|
|
189
339
|
|
|
190
340
|
/**
|
|
341
|
+
*
|
|
191
342
|
* @param {any} o
|
|
343
|
+
* @param {ValidationError} [err]
|
|
192
344
|
* @return {o is T}
|
|
193
345
|
*/
|
|
194
|
-
check (o) {
|
|
195
|
-
|
|
346
|
+
check (o, err) {
|
|
347
|
+
const c = this.shape.some(a => a === o);
|
|
348
|
+
/* c8 ignore next */
|
|
349
|
+
!c && err?.extend(null, this.shape.join(' | '), o.toString());
|
|
350
|
+
return c
|
|
196
351
|
}
|
|
197
352
|
}
|
|
198
353
|
|
|
@@ -201,234 +356,405 @@ class $Literal extends $Schema {
|
|
|
201
356
|
* @param {T} literals
|
|
202
357
|
* @return {CastToSchema<$Literal<T[number]>>}
|
|
203
358
|
*/
|
|
204
|
-
const literal = (...literals) => new $Literal(literals);
|
|
359
|
+
const $literal = (...literals) => new $Literal(literals);
|
|
360
|
+
const $$literal = $constructedBy($Literal);
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @template {Array<string|Schema<string|number>>} Ts
|
|
364
|
+
* @typedef {Ts extends [] ? `` : (Ts extends [infer T] ? (Unwrap<T> extends (string|number) ? Unwrap<T> : never) : (Ts extends [infer T1, ...infer Rest] ? `${Unwrap<T1> extends (string|number) ? Unwrap<T1> : never}${Rest extends Array<string|Schema<string|number>> ? CastStringTemplateArgsToTemplate<Rest> : never}` : never))} CastStringTemplateArgsToTemplate
|
|
365
|
+
*/
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* @param {string} str
|
|
369
|
+
* @return {string}
|
|
370
|
+
*/
|
|
371
|
+
const _regexEscape = /** @type {any} */ (RegExp).escape || /** @type {(str:string) => string} */ (str =>
|
|
372
|
+
str.replace(/[().|&,$^[\]]/g, s => '\\' + s)
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @param {string|Schema<any>} s
|
|
377
|
+
* @return {string[]}
|
|
378
|
+
*/
|
|
379
|
+
const _schemaStringTemplateToRegex = s => {
|
|
380
|
+
if ($string.check(s)) {
|
|
381
|
+
return [_regexEscape(s)]
|
|
382
|
+
}
|
|
383
|
+
if ($$literal.check(s)) {
|
|
384
|
+
return s.shape.map(v => v + '')
|
|
385
|
+
}
|
|
386
|
+
if ($$number.check(s)) {
|
|
387
|
+
return ['[+-]?\\d+.?\\d*']
|
|
388
|
+
}
|
|
389
|
+
if ($$string.check(s)) {
|
|
390
|
+
return ['.*']
|
|
391
|
+
}
|
|
392
|
+
if ($$union.check(s)) {
|
|
393
|
+
return s.shape.map(_schemaStringTemplateToRegex).flat(1)
|
|
394
|
+
}
|
|
395
|
+
/* c8 ignore next 2 */
|
|
396
|
+
// unexpected schema structure (only supports unions and string in literal types)
|
|
397
|
+
error.unexpectedCase();
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @template {Array<string|Schema<string|number>>} T
|
|
402
|
+
* @extends {Schema<CastStringTemplateArgsToTemplate<T>>}
|
|
403
|
+
*/
|
|
404
|
+
class $StringTemplate extends Schema {
|
|
405
|
+
/**
|
|
406
|
+
* @param {T} shape
|
|
407
|
+
*/
|
|
408
|
+
constructor (shape) {
|
|
409
|
+
super();
|
|
410
|
+
this.shape = shape;
|
|
411
|
+
this._r = new RegExp('^' + shape.map(_schemaStringTemplateToRegex).map(opts => `(${opts.join('|')})`).join('') + '$');
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @param {any} o
|
|
416
|
+
* @param {ValidationError} [err]
|
|
417
|
+
* @return {o is CastStringTemplateArgsToTemplate<T>}
|
|
418
|
+
*/
|
|
419
|
+
check (o, err) {
|
|
420
|
+
const c = this._r.exec(o) != null;
|
|
421
|
+
/* c8 ignore next */
|
|
422
|
+
!c && err?.extend(null, this._r.toString(), o.toString(), 'String doesn\'t match string template.');
|
|
423
|
+
return c
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @template {Array<string|Schema<string|number>>} T
|
|
429
|
+
* @param {T} literals
|
|
430
|
+
* @return {CastToSchema<$StringTemplate<T>>}
|
|
431
|
+
*/
|
|
432
|
+
const $stringTemplate = (...literals) => new $StringTemplate(literals);
|
|
433
|
+
const $$stringTemplate = $constructedBy($StringTemplate);
|
|
205
434
|
|
|
206
435
|
const isOptionalSymbol = Symbol('optional');
|
|
207
436
|
/**
|
|
208
|
-
* @template {
|
|
209
|
-
* @extends
|
|
437
|
+
* @template {Schema<any>} S
|
|
438
|
+
* @extends Schema<Unwrap<S>|undefined>
|
|
210
439
|
*/
|
|
211
|
-
class $Optional extends
|
|
440
|
+
class $Optional extends Schema {
|
|
212
441
|
/**
|
|
213
|
-
* @param {S}
|
|
442
|
+
* @param {S} shape
|
|
214
443
|
*/
|
|
215
|
-
constructor (
|
|
444
|
+
constructor (shape) {
|
|
216
445
|
super();
|
|
217
|
-
this.
|
|
446
|
+
this.shape = shape;
|
|
218
447
|
}
|
|
219
448
|
|
|
220
449
|
/**
|
|
221
450
|
* @param {any} o
|
|
451
|
+
* @param {ValidationError} [err]
|
|
222
452
|
* @return {o is (Unwrap<S>|undefined)}
|
|
223
453
|
*/
|
|
224
|
-
check (o) {
|
|
225
|
-
|
|
454
|
+
check (o, err) {
|
|
455
|
+
const c = o === undefined || this.shape.check(o);
|
|
456
|
+
/* c8 ignore next */
|
|
457
|
+
!c && err?.extend(null, 'undefined (optional)', '()');
|
|
458
|
+
return c
|
|
226
459
|
}
|
|
227
460
|
|
|
228
461
|
get [isOptionalSymbol] () { return true }
|
|
229
462
|
}
|
|
463
|
+
const $$optional = $constructedBy($Optional);
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* @extends Schema<never>
|
|
467
|
+
*/
|
|
468
|
+
class $Never extends Schema {
|
|
469
|
+
/**
|
|
470
|
+
* @param {any} _o
|
|
471
|
+
* @param {ValidationError} [err]
|
|
472
|
+
* @return {_o is never}
|
|
473
|
+
*/
|
|
474
|
+
check (_o, err) {
|
|
475
|
+
err?.extend(null, 'never', typeof _o);
|
|
476
|
+
return false
|
|
477
|
+
}
|
|
478
|
+
}
|
|
230
479
|
|
|
231
480
|
/**
|
|
232
|
-
* @
|
|
233
|
-
* @typedef {{ [Key in keyof S as S[Key] extends $Optional<$Schema<any>> ? Key : never]?: S[Key] extends $Optional<$Schema<infer Type>> ? Type : never } & { [Key in keyof S as S[Key] extends $Optional<$Schema<any>> ? never : Key]: S[Key] extends $Schema<infer Type> ? Type : never }} $ObjectToType
|
|
481
|
+
* @type {Schema<never>}
|
|
234
482
|
*/
|
|
483
|
+
const $never = new $Never();
|
|
484
|
+
const $$never = $constructedBy($Never);
|
|
235
485
|
|
|
236
486
|
/**
|
|
237
|
-
* @template {{[key:string|symbol|number]:
|
|
238
|
-
* @extends
|
|
487
|
+
* @template {{ [key: string|symbol|number]: Schema<any> }} S
|
|
488
|
+
* @typedef {{ [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never } & { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never }} $ObjectToType
|
|
239
489
|
*/
|
|
240
|
-
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* @template {{[key:string|symbol|number]: Schema<any>}} S
|
|
493
|
+
* @extends {Schema<$ObjectToType<S>>}
|
|
494
|
+
*/
|
|
495
|
+
class $Object extends Schema {
|
|
241
496
|
/**
|
|
242
|
-
* @param {S}
|
|
497
|
+
* @param {S} shape
|
|
498
|
+
* @param {boolean} partial
|
|
243
499
|
*/
|
|
244
|
-
constructor (
|
|
500
|
+
constructor (shape, partial = false) {
|
|
245
501
|
super();
|
|
246
|
-
|
|
502
|
+
/**
|
|
503
|
+
* @type {S}
|
|
504
|
+
*/
|
|
505
|
+
this.shape = shape;
|
|
506
|
+
this._isPartial = partial;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* @type {Schema<Partial<$ObjectToType<S>>>}
|
|
511
|
+
*/
|
|
512
|
+
get partial () {
|
|
513
|
+
return new $Object(this.shape, true)
|
|
247
514
|
}
|
|
248
515
|
|
|
249
516
|
/**
|
|
250
517
|
* @param {any} o
|
|
518
|
+
* @param {ValidationError} err
|
|
251
519
|
* @return {o is $ObjectToType<S>}
|
|
252
520
|
*/
|
|
253
|
-
check (o) {
|
|
254
|
-
|
|
521
|
+
check (o, err) {
|
|
522
|
+
if (o == null) {
|
|
523
|
+
/* c8 ignore next */
|
|
524
|
+
err?.extend(null, 'object', 'null');
|
|
525
|
+
return false
|
|
526
|
+
}
|
|
527
|
+
return object.every(this.shape, (vv, vk) => {
|
|
528
|
+
const c = (this._isPartial && !object.hasProperty(o, vk)) || vv.check(o[vk], err);
|
|
529
|
+
!c && err?.extend(vk.toString(), vv.toString(), typeof o[vk], 'Object property does not match');
|
|
530
|
+
return c
|
|
531
|
+
})
|
|
255
532
|
}
|
|
256
533
|
}
|
|
257
534
|
|
|
535
|
+
/**
|
|
536
|
+
* @template {{ [key:string|symbol|number]: Schema<any> }} S
|
|
537
|
+
* @typedef {Schema<{ [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never } & { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never }>} _ObjectDefToSchema
|
|
538
|
+
*/
|
|
539
|
+
|
|
258
540
|
// I used an explicit type annotation instead of $ObjectToType, so that the user doesn't see the
|
|
259
541
|
// weird type definitions when inspecting type definions.
|
|
260
542
|
/**
|
|
261
|
-
* @template {{ [key:string|symbol|number]:
|
|
543
|
+
* @template {{ [key:string|symbol|number]: Schema<any> }} S
|
|
262
544
|
* @param {S} def
|
|
263
|
-
* @return {
|
|
545
|
+
* @return {_ObjectDefToSchema<S> extends Schema<infer S> ? Schema<S> : never}
|
|
264
546
|
*/
|
|
265
|
-
const object = def => /** @type {any} */ (new $Object(def));
|
|
547
|
+
const $object = def => /** @type {any} */ (new $Object(def));
|
|
548
|
+
const $$object = $constructedBy($Object);
|
|
549
|
+
/**
|
|
550
|
+
* @type {Schema<{[key:string]: any}>}
|
|
551
|
+
*/
|
|
552
|
+
const $objectAny = $custom(o => o != null && (o.constructor == null || o.constructor === Object));
|
|
266
553
|
|
|
267
554
|
/**
|
|
268
|
-
* @template {
|
|
269
|
-
* @template {
|
|
270
|
-
* @extends {
|
|
555
|
+
* @template {Schema<string|number|symbol>} Keys
|
|
556
|
+
* @template {Schema<any>} Values
|
|
557
|
+
* @extends {Schema<{ [key in Unwrap<Keys>]: Unwrap<Values> }>}
|
|
271
558
|
*/
|
|
272
|
-
class $Record extends
|
|
559
|
+
class $Record extends Schema {
|
|
273
560
|
/**
|
|
274
561
|
* @param {Keys} keys
|
|
275
562
|
* @param {Values} values
|
|
276
563
|
*/
|
|
277
564
|
constructor (keys, values) {
|
|
278
565
|
super();
|
|
279
|
-
this.
|
|
280
|
-
|
|
566
|
+
this.shape = {
|
|
567
|
+
keys, values
|
|
568
|
+
};
|
|
281
569
|
}
|
|
282
570
|
|
|
283
571
|
/**
|
|
284
572
|
* @param {any} o
|
|
285
|
-
* @
|
|
573
|
+
* @param {ValidationError} err
|
|
574
|
+
* @return {o is { [key in Unwrap<Keys>]: Unwrap<Values> }}
|
|
286
575
|
*/
|
|
287
|
-
check (o) {
|
|
288
|
-
return o != null && object
|
|
576
|
+
check (o, err) {
|
|
577
|
+
return o != null && object.every(o, (vv, vk) => {
|
|
578
|
+
const ck = this.shape.keys.check(vk, err);
|
|
579
|
+
/* c8 ignore next */
|
|
580
|
+
!ck && err?.extend(vk + '', 'Record', typeof o, ck ? 'Key doesn\'t match schema' : 'Value doesn\'t match value');
|
|
581
|
+
return ck && this.shape.values.check(vv, err)
|
|
582
|
+
})
|
|
289
583
|
}
|
|
290
584
|
}
|
|
291
585
|
|
|
292
586
|
/**
|
|
293
|
-
* @template {
|
|
294
|
-
* @template {
|
|
587
|
+
* @template {Schema<string|number|symbol>} Keys
|
|
588
|
+
* @template {Schema<any>} Values
|
|
295
589
|
* @param {Keys} keys
|
|
296
590
|
* @param {Values} values
|
|
297
591
|
* @return {CastToSchema<$Record<Keys,Values>>}
|
|
298
592
|
*/
|
|
299
|
-
const record = (keys, values) => new $Record(keys, values);
|
|
593
|
+
const $record = (keys, values) => new $Record(keys, values);
|
|
594
|
+
const $$record = $constructedBy($Record);
|
|
300
595
|
|
|
301
596
|
/**
|
|
302
|
-
* @template {
|
|
303
|
-
* @extends {
|
|
597
|
+
* @template {Schema<any>[]} S
|
|
598
|
+
* @extends {Schema<{ [Key in keyof S]: S[Key] extends Schema<infer Type> ? Type : never }>}
|
|
304
599
|
*/
|
|
305
|
-
class $Tuple extends
|
|
600
|
+
class $Tuple extends Schema {
|
|
306
601
|
/**
|
|
307
|
-
* @param {S}
|
|
602
|
+
* @param {S} shape
|
|
308
603
|
*/
|
|
309
|
-
constructor (
|
|
604
|
+
constructor (shape) {
|
|
310
605
|
super();
|
|
311
|
-
this.
|
|
606
|
+
this.shape = shape;
|
|
312
607
|
}
|
|
313
608
|
|
|
314
609
|
/**
|
|
315
610
|
* @param {any} o
|
|
316
|
-
* @
|
|
611
|
+
* @param {ValidationError} err
|
|
612
|
+
* @return {o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never }}
|
|
317
613
|
*/
|
|
318
|
-
check (o) {
|
|
319
|
-
return o != null && object
|
|
614
|
+
check (o, err) {
|
|
615
|
+
return o != null && object.every(this.shape, (vv, vk) => {
|
|
616
|
+
const c = /** @type {Schema<any>} */ (vv).check(o[vk], err);
|
|
617
|
+
/* c8 ignore next */
|
|
618
|
+
!c && err?.extend(vk.toString(), 'Tuple', typeof vv);
|
|
619
|
+
return c
|
|
620
|
+
})
|
|
320
621
|
}
|
|
321
622
|
}
|
|
322
623
|
|
|
323
624
|
/**
|
|
324
|
-
* @template {Array
|
|
625
|
+
* @template {Array<Schema<any>>} T
|
|
325
626
|
* @param {T} def
|
|
326
627
|
* @return {CastToSchema<$Tuple<T>>}
|
|
327
628
|
*/
|
|
328
|
-
const tuple = (...def) => new $Tuple(def);
|
|
629
|
+
const $tuple = (...def) => new $Tuple(def);
|
|
630
|
+
const $$tuple = $constructedBy($Tuple);
|
|
329
631
|
|
|
330
632
|
/**
|
|
331
|
-
* @template {
|
|
332
|
-
* @extends {
|
|
633
|
+
* @template {Schema<any>} S
|
|
634
|
+
* @extends {Schema<Array<S extends Schema<infer T> ? T : never>>}
|
|
333
635
|
*/
|
|
334
|
-
class $Array extends
|
|
636
|
+
class $Array extends Schema {
|
|
335
637
|
/**
|
|
336
638
|
* @param {Array<S>} v
|
|
337
639
|
*/
|
|
338
640
|
constructor (v) {
|
|
339
641
|
super();
|
|
340
642
|
/**
|
|
341
|
-
* @type {
|
|
643
|
+
* @type {Schema<S extends Schema<infer T> ? T : never>}
|
|
342
644
|
*/
|
|
343
|
-
this.
|
|
645
|
+
this.shape = v.length === 1 ? v[0] : new $Union(v);
|
|
344
646
|
}
|
|
345
647
|
|
|
346
648
|
/**
|
|
347
649
|
* @param {any} o
|
|
348
|
-
* @
|
|
650
|
+
* @param {ValidationError} [err]
|
|
651
|
+
* @return {o is Array<S extends Schema<infer T> ? T : never>} o
|
|
349
652
|
*/
|
|
350
|
-
check (o) {
|
|
351
|
-
|
|
653
|
+
check (o, err) {
|
|
654
|
+
const c = array.isArray(o) && array.every(o, oi => this.shape.check(oi));
|
|
655
|
+
/* c8 ignore next */
|
|
656
|
+
!c && err?.extend(null, 'Array', '');
|
|
657
|
+
return c
|
|
352
658
|
}
|
|
353
659
|
}
|
|
354
660
|
|
|
355
661
|
/**
|
|
356
|
-
* @template {Array
|
|
662
|
+
* @template {Array<Schema<any>>} T
|
|
357
663
|
* @param {T} def
|
|
358
|
-
* @return {
|
|
664
|
+
* @return {Schema<Array<T extends Array<Schema<infer S>> ? S : never>>}
|
|
359
665
|
*/
|
|
360
|
-
const array = (...def) => new $Array(def);
|
|
666
|
+
const $array = (...def) => new $Array(def);
|
|
667
|
+
const $$array = $constructedBy($Array);
|
|
668
|
+
/**
|
|
669
|
+
* @type {Schema<Array<any>>}
|
|
670
|
+
*/
|
|
671
|
+
const $arrayAny = $custom(o => array.isArray(o));
|
|
361
672
|
|
|
362
673
|
/**
|
|
363
674
|
* @template T
|
|
364
|
-
* @extends {
|
|
675
|
+
* @extends {Schema<T>}
|
|
365
676
|
*/
|
|
366
|
-
class $InstanceOf extends
|
|
677
|
+
class $InstanceOf extends Schema {
|
|
367
678
|
/**
|
|
368
679
|
* @param {new (...args:any) => T} constructor
|
|
680
|
+
* @param {((o:T) => boolean)|null} check
|
|
369
681
|
*/
|
|
370
|
-
constructor (constructor) {
|
|
682
|
+
constructor (constructor, check) {
|
|
371
683
|
super();
|
|
372
|
-
this.
|
|
684
|
+
this.shape = constructor;
|
|
685
|
+
this._c = check;
|
|
373
686
|
}
|
|
374
687
|
|
|
375
688
|
/**
|
|
376
689
|
* @param {any} o
|
|
690
|
+
* @param {ValidationError} err
|
|
377
691
|
* @return {o is T}
|
|
378
692
|
*/
|
|
379
|
-
check (o) {
|
|
380
|
-
|
|
693
|
+
check (o, err) {
|
|
694
|
+
const c = o instanceof this.shape && (this._c == null || this._c(o));
|
|
695
|
+
/* c8 ignore next */
|
|
696
|
+
!c && err?.extend(null, this.shape.name, o?.constructor.name);
|
|
697
|
+
return c
|
|
381
698
|
}
|
|
382
699
|
}
|
|
383
700
|
|
|
384
701
|
/**
|
|
385
702
|
* @template T
|
|
386
703
|
* @param {new (...args:any) => T} c
|
|
387
|
-
* @
|
|
704
|
+
* @param {((o:T) => boolean)|null} check
|
|
705
|
+
* @return {Schema<T>}
|
|
388
706
|
*/
|
|
389
|
-
const
|
|
707
|
+
const $instanceOf = (c, check = null) => new $InstanceOf(c, check);
|
|
708
|
+
const $$instanceOf = $constructedBy($InstanceOf);
|
|
709
|
+
|
|
710
|
+
const $$schema = $instanceOf(Schema);
|
|
390
711
|
|
|
391
712
|
/**
|
|
392
|
-
* @template {
|
|
713
|
+
* @template {Schema<any>[]} Args
|
|
393
714
|
* @typedef {(...args:UnwrapArray<TuplePop<Args>>)=>Unwrap<TupleLast<Args>>} _LArgsToLambdaDef
|
|
394
715
|
*/
|
|
395
716
|
|
|
396
717
|
/**
|
|
397
|
-
* @template {Array
|
|
398
|
-
* @extends {
|
|
718
|
+
* @template {Array<Schema<any>>} Args
|
|
719
|
+
* @extends {Schema<_LArgsToLambdaDef<Args>>}
|
|
399
720
|
*/
|
|
400
|
-
class $Lambda extends
|
|
721
|
+
class $Lambda extends Schema {
|
|
401
722
|
/**
|
|
402
723
|
* @param {Args} args
|
|
403
724
|
*/
|
|
404
725
|
constructor (args) {
|
|
405
726
|
super();
|
|
406
727
|
this.len = args.length - 1;
|
|
407
|
-
this.args = tuple(...args.slice(-1));
|
|
728
|
+
this.args = $tuple(...args.slice(-1));
|
|
408
729
|
this.res = args[this.len];
|
|
409
730
|
}
|
|
410
731
|
|
|
411
732
|
/**
|
|
412
733
|
* @param {any} f
|
|
734
|
+
* @param {ValidationError} err
|
|
413
735
|
* @return {f is _LArgsToLambdaDef<Args>}
|
|
414
736
|
*/
|
|
415
|
-
check (f) {
|
|
416
|
-
|
|
737
|
+
check (f, err) {
|
|
738
|
+
const c = f.constructor === Function && f.length <= this.len;
|
|
739
|
+
/* c8 ignore next */
|
|
740
|
+
!c && err?.extend(null, 'function', typeof f);
|
|
741
|
+
return c
|
|
417
742
|
}
|
|
418
743
|
}
|
|
419
744
|
|
|
420
745
|
/**
|
|
421
|
-
* @template {
|
|
746
|
+
* @template {Schema<any>[]} Args
|
|
422
747
|
* @param {Args} args
|
|
423
|
-
* @return {
|
|
748
|
+
* @return {Schema<(...args:UnwrapArray<TuplePop<Args>>)=>Unwrap<TupleLast<Args>>>}
|
|
424
749
|
*/
|
|
425
|
-
const lambda = (...args) => new $Lambda(args.length > 0 ? args : [
|
|
750
|
+
const $lambda = (...args) => new $Lambda(args.length > 0 ? args : [$void]);
|
|
751
|
+
const $$lambda = $constructedBy($Lambda);
|
|
426
752
|
|
|
427
753
|
/**
|
|
428
|
-
* @template {Array
|
|
429
|
-
* @extends {
|
|
754
|
+
* @template {Array<Schema<any>>} T
|
|
755
|
+
* @extends {Schema<Intersect<UnwrapArray<T>>>}
|
|
430
756
|
*/
|
|
431
|
-
class $Intersection extends
|
|
757
|
+
class $Intersection extends Schema {
|
|
432
758
|
/**
|
|
433
759
|
* @param {T} v
|
|
434
760
|
*/
|
|
@@ -437,141 +763,220 @@ class $Intersection extends $Schema {
|
|
|
437
763
|
/**
|
|
438
764
|
* @type {T}
|
|
439
765
|
*/
|
|
440
|
-
this.
|
|
766
|
+
this.shape = v;
|
|
441
767
|
}
|
|
442
768
|
|
|
443
769
|
/**
|
|
444
770
|
* @param {any} o
|
|
771
|
+
* @param {ValidationError} [err]
|
|
445
772
|
* @return {o is Intersect<UnwrapArray<T>>}
|
|
446
773
|
*/
|
|
447
|
-
check (o) {
|
|
774
|
+
check (o, err) {
|
|
448
775
|
// @ts-ignore
|
|
449
|
-
|
|
776
|
+
const c = array.every(this.shape, check => check.check(o, err));
|
|
777
|
+
/* c8 ignore next */
|
|
778
|
+
!c && err?.extend(null, 'Intersectinon', typeof o);
|
|
779
|
+
return c
|
|
450
780
|
}
|
|
451
781
|
}
|
|
452
782
|
|
|
453
783
|
/**
|
|
454
|
-
* @template {
|
|
784
|
+
* @template {Schema<any>[]} T
|
|
455
785
|
* @param {T} def
|
|
456
786
|
* @return {CastToSchema<$Intersection<T>>}
|
|
457
787
|
*/
|
|
458
|
-
const intersect = (...def) => new $Intersection(def);
|
|
788
|
+
const $intersect = (...def) => new $Intersection(def);
|
|
789
|
+
const $$intersect = $constructedBy($Intersection, o => o.shape.length > 0); // Intersection with length=0 is considered "any"
|
|
459
790
|
|
|
460
791
|
/**
|
|
461
792
|
* @template S
|
|
462
|
-
* @extends {
|
|
793
|
+
* @extends {Schema<S>}
|
|
463
794
|
*/
|
|
464
|
-
class $Union extends
|
|
795
|
+
class $Union extends Schema {
|
|
796
|
+
static _dilutes = true
|
|
797
|
+
|
|
465
798
|
/**
|
|
466
|
-
* @param {Array
|
|
799
|
+
* @param {Array<Schema<S>>} v
|
|
467
800
|
*/
|
|
468
801
|
constructor (v) {
|
|
469
802
|
super();
|
|
470
|
-
this.
|
|
803
|
+
this.shape = v;
|
|
471
804
|
}
|
|
472
805
|
|
|
473
806
|
/**
|
|
474
807
|
* @param {any} o
|
|
808
|
+
* @param {ValidationError} [err]
|
|
475
809
|
* @return {o is S}
|
|
476
810
|
*/
|
|
477
|
-
check (o) {
|
|
478
|
-
|
|
811
|
+
check (o, err) {
|
|
812
|
+
const c = array.some(this.shape, (vv) => vv.check(o, err));
|
|
813
|
+
err?.extend(null, 'Union', typeof o);
|
|
814
|
+
return c
|
|
479
815
|
}
|
|
480
|
-
|
|
481
|
-
static schema = constructedBy($Union)
|
|
482
816
|
}
|
|
483
817
|
|
|
484
818
|
/**
|
|
485
|
-
* @template {Array
|
|
486
|
-
* @param {T}
|
|
487
|
-
* @return {CastToSchema<$Union<T extends [] ? never : (T extends Array
|
|
819
|
+
* @template {Array<Schema<any>>} T
|
|
820
|
+
* @param {T} schemas
|
|
821
|
+
* @return {CastToSchema<$Union<T extends [] ? never : (T extends Array<Schema<infer S>> ? S : never)>>}
|
|
822
|
+
*/
|
|
823
|
+
const $union = (...schemas) => $$union.check(schemas[0]) ? new $Union([...schemas[0].shape, ...schemas.slice(1)]) : (schemas.length === 1 ? schemas[0] : new $Union(schemas));
|
|
824
|
+
const $$union = /** @type {Schema<$Union<any>>} */ ($constructedBy($Union));
|
|
825
|
+
|
|
826
|
+
const _t = () => true;
|
|
827
|
+
/**
|
|
828
|
+
* @type {Schema<any>}
|
|
488
829
|
*/
|
|
489
|
-
const
|
|
830
|
+
const $any = $custom(_t);
|
|
831
|
+
const $$any = /** @type {Schema<Schema<any>>} */ ($constructedBy($Custom, o => o.shape === _t));
|
|
490
832
|
|
|
491
833
|
/**
|
|
492
|
-
* @type {
|
|
834
|
+
* @type {Schema<bigint>}
|
|
493
835
|
*/
|
|
494
|
-
const
|
|
836
|
+
const $bigint = $constructedBy(BigInt);
|
|
837
|
+
const $$bigint = /** @type {Schema<Schema<BigInt>>} */ ($constructedBy($ConstructedBy, o => o.shape === BigInt));
|
|
495
838
|
|
|
496
839
|
/**
|
|
497
|
-
* @type {
|
|
840
|
+
* @type {Schema<Symbol>}
|
|
498
841
|
*/
|
|
499
|
-
const
|
|
842
|
+
const $symbol = $constructedBy(Symbol);
|
|
843
|
+
const $$symbol = /** @type {Schema<Schema<Symbol>>} */ ($constructedBy($ConstructedBy, o => o.shape === Symbol));
|
|
500
844
|
|
|
501
845
|
/**
|
|
502
|
-
* @type {
|
|
846
|
+
* @type {Schema<number>}
|
|
503
847
|
*/
|
|
504
|
-
const
|
|
848
|
+
const $number = $constructedBy(Number);
|
|
849
|
+
const $$number = /** @type {Schema<Schema<number>>} */ ($constructedBy($ConstructedBy, o => o.shape === Number));
|
|
505
850
|
|
|
506
851
|
/**
|
|
507
|
-
* @type {
|
|
852
|
+
* @type {Schema<string>}
|
|
508
853
|
*/
|
|
509
|
-
const
|
|
854
|
+
const $string = $constructedBy(String);
|
|
855
|
+
const $$string = /** @type {Schema<Schema<string>>} */ ($constructedBy($ConstructedBy, o => o.shape === String));
|
|
510
856
|
|
|
511
857
|
/**
|
|
512
|
-
* @type {
|
|
858
|
+
* @type {Schema<boolean>}
|
|
513
859
|
*/
|
|
514
|
-
const
|
|
860
|
+
const $boolean = $constructedBy(Boolean);
|
|
861
|
+
const $$boolean = /** @type {Schema<Schema<Boolean>>} */ ($constructedBy($ConstructedBy, o => o.shape === Boolean));
|
|
515
862
|
|
|
516
863
|
/**
|
|
517
|
-
* @type {
|
|
864
|
+
* @type {Schema<undefined>}
|
|
518
865
|
*/
|
|
519
|
-
const
|
|
866
|
+
const $undefined = $literal(undefined);
|
|
867
|
+
const $$undefined = /** @type {Schema<Schema<undefined>>} */ ($constructedBy($Literal, o => o.shape.length === 1 && o.shape[0] === undefined));
|
|
520
868
|
|
|
521
869
|
/**
|
|
522
|
-
* @type {
|
|
870
|
+
* @type {Schema<void>}
|
|
523
871
|
*/
|
|
524
|
-
const
|
|
872
|
+
const $void = $literal(undefined);
|
|
873
|
+
const $$void = /** @type {Schema<Schema<void>>} */ ($$undefined);
|
|
525
874
|
|
|
875
|
+
const $null = $literal(null);
|
|
876
|
+
const $$null = /** @type {Schema<Schema<null>>} */ ($constructedBy($Literal, o => o.shape.length === 1 && o.shape[0] === null));
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* @type {Schema<number|string|null|boolean>}
|
|
880
|
+
*/
|
|
881
|
+
const $primitive = $union($number, $string, $null, $boolean);
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* @typedef {JSON[]} JSONArray
|
|
885
|
+
*/
|
|
886
|
+
/**
|
|
887
|
+
* @typedef {Unwrap<$primitive>|JSONArray|{ [key:string]:JSON }} JSON
|
|
888
|
+
*/
|
|
526
889
|
/**
|
|
527
|
-
* @type {
|
|
890
|
+
* @type {Schema<null|number|string|boolean|JSON[]|{[key:string]:JSON}>}
|
|
528
891
|
*/
|
|
529
|
-
const
|
|
892
|
+
const $json = (() => {
|
|
893
|
+
const $jsonArr = /** @type {$Array<$any>} */ ($array($any));
|
|
894
|
+
const $jsonRecord = /** @type {$Record<$string,$any>} */ ($record($string, $any));
|
|
895
|
+
const $json = $union($number, $string, $null, $boolean, $jsonArr, $jsonRecord);
|
|
896
|
+
$jsonArr.shape = $json;
|
|
897
|
+
$jsonRecord.shape.values = $json;
|
|
898
|
+
return $json
|
|
899
|
+
})();
|
|
530
900
|
|
|
531
901
|
/* c8 ignore start */
|
|
532
902
|
/**
|
|
533
903
|
* Assert that a variable is of this specific type.
|
|
534
904
|
* The assertion check is only performed in non-production environments.
|
|
535
905
|
*
|
|
536
|
-
* @type {<T>(o:any,schema
|
|
906
|
+
* @type {<T>(o:any,schema:Schema<T>) => asserts o is T}
|
|
537
907
|
*/
|
|
538
908
|
const assert = environment.production
|
|
539
909
|
? () => {}
|
|
540
910
|
: (o, schema) => {
|
|
541
|
-
|
|
542
|
-
|
|
911
|
+
const err = new ValidationError();
|
|
912
|
+
if (!schema.check(o, err)) {
|
|
913
|
+
throw error.create(`Expected value to be of type ${schema.constructor.name}.\n${err.toString()}`)
|
|
543
914
|
}
|
|
544
915
|
};
|
|
545
916
|
/* c8 ignore end */
|
|
546
917
|
|
|
918
|
+
exports.$$any = $$any;
|
|
919
|
+
exports.$$array = $$array;
|
|
920
|
+
exports.$$bigint = $$bigint;
|
|
921
|
+
exports.$$boolean = $$boolean;
|
|
922
|
+
exports.$$constructedBy = $$constructedBy;
|
|
923
|
+
exports.$$custom = $$custom;
|
|
924
|
+
exports.$$instanceOf = $$instanceOf;
|
|
925
|
+
exports.$$intersect = $$intersect;
|
|
926
|
+
exports.$$lambda = $$lambda;
|
|
927
|
+
exports.$$literal = $$literal;
|
|
928
|
+
exports.$$never = $$never;
|
|
929
|
+
exports.$$null = $$null;
|
|
930
|
+
exports.$$number = $$number;
|
|
931
|
+
exports.$$object = $$object;
|
|
932
|
+
exports.$$optional = $$optional;
|
|
933
|
+
exports.$$record = $$record;
|
|
934
|
+
exports.$$schema = $$schema;
|
|
935
|
+
exports.$$string = $$string;
|
|
936
|
+
exports.$$stringTemplate = $$stringTemplate;
|
|
937
|
+
exports.$$symbol = $$symbol;
|
|
938
|
+
exports.$$tuple = $$tuple;
|
|
939
|
+
exports.$$undefined = $$undefined;
|
|
940
|
+
exports.$$union = $$union;
|
|
941
|
+
exports.$$void = $$void;
|
|
547
942
|
exports.$Array = $Array;
|
|
548
943
|
exports.$ConstructedBy = $ConstructedBy;
|
|
944
|
+
exports.$Custom = $Custom;
|
|
549
945
|
exports.$InstanceOf = $InstanceOf;
|
|
550
946
|
exports.$Intersection = $Intersection;
|
|
551
947
|
exports.$Lambda = $Lambda;
|
|
552
948
|
exports.$Literal = $Literal;
|
|
553
949
|
exports.$Object = $Object;
|
|
554
950
|
exports.$Record = $Record;
|
|
555
|
-
exports.$
|
|
951
|
+
exports.$StringTemplate = $StringTemplate;
|
|
556
952
|
exports.$Tuple = $Tuple;
|
|
557
953
|
exports.$Union = $Union;
|
|
558
|
-
exports
|
|
559
|
-
exports
|
|
954
|
+
exports.$any = $any;
|
|
955
|
+
exports.$array = $array;
|
|
956
|
+
exports.$arrayAny = $arrayAny;
|
|
957
|
+
exports.$bigint = $bigint;
|
|
958
|
+
exports.$boolean = $boolean;
|
|
959
|
+
exports.$constructedBy = $constructedBy;
|
|
960
|
+
exports.$custom = $custom;
|
|
961
|
+
exports.$instanceOf = $instanceOf;
|
|
962
|
+
exports.$intersect = $intersect;
|
|
963
|
+
exports.$json = $json;
|
|
964
|
+
exports.$lambda = $lambda;
|
|
965
|
+
exports.$literal = $literal;
|
|
966
|
+
exports.$never = $never;
|
|
967
|
+
exports.$null = $null;
|
|
968
|
+
exports.$number = $number;
|
|
969
|
+
exports.$object = $object;
|
|
970
|
+
exports.$objectAny = $objectAny;
|
|
971
|
+
exports.$primitive = $primitive;
|
|
972
|
+
exports.$record = $record;
|
|
973
|
+
exports.$string = $string;
|
|
974
|
+
exports.$stringTemplate = $stringTemplate;
|
|
975
|
+
exports.$symbol = $symbol;
|
|
976
|
+
exports.$tuple = $tuple;
|
|
977
|
+
exports.$undefined = $undefined;
|
|
978
|
+
exports.$union = $union;
|
|
979
|
+
exports.$void = $void;
|
|
980
|
+
exports.Schema = Schema;
|
|
560
981
|
exports.assert = assert;
|
|
561
|
-
exports.bigint = bigint;
|
|
562
|
-
exports.constructedBy = constructedBy;
|
|
563
|
-
exports.instance = instance;
|
|
564
|
-
exports.intersect = intersect;
|
|
565
|
-
exports.lambda = lambda;
|
|
566
|
-
exports.literal = literal;
|
|
567
|
-
exports["null"] = null_;
|
|
568
|
-
exports.number = number;
|
|
569
|
-
exports.object = object;
|
|
570
|
-
exports.record = record;
|
|
571
|
-
exports.string = string;
|
|
572
|
-
exports.symbol = symbol;
|
|
573
|
-
exports.tuple = tuple;
|
|
574
|
-
exports["undefined"] = undefined_;
|
|
575
|
-
exports.union = union;
|
|
576
|
-
exports["void"] = void_;
|
|
577
982
|
//# sourceMappingURL=schema.cjs.map
|