typesea 0.1.0 → 0.3.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/CHANGELOG.md +85 -6
- package/README.md +143 -28
- package/dist/adapters/index.d.ts +50 -8
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +169 -48
- package/dist/aot/index.d.ts +19 -3
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +115 -17
- package/dist/async/index.d.ts +28 -56
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +94 -37
- package/dist/builders/composite.d.ts +43 -9
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +100 -17
- package/dist/builders/index.d.ts +8 -5
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +7 -4
- package/dist/builders/modifier.d.ts +36 -5
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +52 -5
- package/dist/builders/object/guard.d.ts +72 -24
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +139 -29
- package/dist/builders/object/index.d.ts +4 -2
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +3 -1
- package/dist/builders/object/schema.d.ts +88 -11
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +290 -23
- package/dist/builders/object/types.d.ts +20 -31
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/object/types.js +2 -0
- package/dist/builders/runtime.d.ts +40 -0
- package/dist/builders/runtime.d.ts.map +1 -0
- package/dist/builders/runtime.js +150 -0
- package/dist/builders/scalar.d.ts +49 -9
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +87 -9
- package/dist/builders/table.d.ts +35 -5
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +35 -5
- package/dist/builders/types.d.ts +20 -4
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/builders/types.js +2 -0
- package/dist/compile/check-composite.d.ts +25 -2
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +699 -27
- package/dist/compile/check-scalar.d.ts +88 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +570 -3
- package/dist/compile/check.d.ts +12 -0
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +62 -3
- package/dist/compile/context.d.ts +47 -9
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +53 -8
- package/dist/compile/first.d.ts +26 -0
- package/dist/compile/first.d.ts.map +1 -0
- package/dist/compile/first.js +850 -0
- package/dist/compile/graph-predicate.d.ts +4 -2
- package/dist/compile/graph-predicate.d.ts.map +1 -1
- package/dist/compile/graph-predicate.js +2272 -165
- package/dist/compile/guard.d.ts +16 -24
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +202 -72
- package/dist/compile/index.d.ts +3 -1
- package/dist/compile/index.d.ts.map +1 -1
- package/dist/compile/index.js +2 -0
- package/dist/compile/issue.d.ts +110 -0
- package/dist/compile/issue.d.ts.map +1 -1
- package/dist/compile/issue.js +184 -1
- package/dist/compile/names.d.ts +12 -2
- package/dist/compile/names.d.ts.map +1 -1
- package/dist/compile/names.js +19 -3
- package/dist/compile/predicate.d.ts +24 -0
- package/dist/compile/predicate.d.ts.map +1 -1
- package/dist/compile/predicate.js +287 -10
- package/dist/compile/runtime.d.ts +100 -13
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +56 -6
- package/dist/compile/source.d.ts +10 -2
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +385 -26
- package/dist/compile/types.d.ts +22 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/compile/types.js +2 -0
- package/dist/decoder/index.d.ts +92 -46
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +266 -39
- package/dist/evaluate/check-composite.d.ts +111 -2
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +343 -8
- package/dist/evaluate/check-scalar.d.ts +25 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +124 -3
- package/dist/evaluate/check.d.ts +7 -0
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +62 -4
- package/dist/evaluate/index.d.ts +2 -0
- package/dist/evaluate/index.d.ts.map +1 -1
- package/dist/evaluate/index.js +2 -0
- package/dist/evaluate/issue.d.ts +11 -1
- package/dist/evaluate/issue.d.ts.map +1 -1
- package/dist/evaluate/issue.js +15 -1
- package/dist/evaluate/predicate.d.ts +16 -5
- package/dist/evaluate/predicate.d.ts.map +1 -1
- package/dist/evaluate/predicate.js +20 -5
- package/dist/evaluate/shared.d.ts +78 -13
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +101 -8
- package/dist/evaluate/state.d.ts +35 -13
- package/dist/evaluate/state.d.ts.map +1 -1
- package/dist/evaluate/state.js +35 -2
- package/dist/guard/array.d.ts +48 -0
- package/dist/guard/array.d.ts.map +1 -0
- package/dist/guard/array.js +84 -0
- package/dist/guard/base.d.ts +111 -31
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +165 -32
- package/dist/guard/date.d.ts +34 -0
- package/dist/guard/date.d.ts.map +1 -0
- package/dist/guard/date.js +60 -0
- package/dist/guard/error.d.ts +10 -5
- package/dist/guard/error.d.ts.map +1 -1
- package/dist/guard/error.js +10 -5
- package/dist/guard/index.d.ts +4 -0
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +4 -0
- package/dist/guard/number.d.ts +86 -11
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +159 -11
- package/dist/guard/props.d.ts +27 -3
- package/dist/guard/props.d.ts.map +1 -1
- package/dist/guard/props.js +27 -3
- package/dist/guard/read.d.ts +115 -10
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +185 -10
- package/dist/guard/registry.d.ts +12 -2
- package/dist/guard/registry.d.ts.map +1 -1
- package/dist/guard/registry.js +15 -3
- package/dist/guard/string.d.ts +115 -13
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +250 -13
- package/dist/guard/types.d.ts +110 -40
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/types.js +2 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/internal/index.d.ts +42 -6
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +51 -8
- package/dist/ir/builder.d.ts +17 -127
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +80 -137
- package/dist/ir/freeze.d.ts +4 -0
- package/dist/ir/freeze.d.ts.map +1 -1
- package/dist/ir/freeze.js +66 -0
- package/dist/ir/index.d.ts +3 -1
- package/dist/ir/index.d.ts.map +1 -1
- package/dist/ir/index.js +2 -0
- package/dist/ir/regexp.d.ts +2 -0
- package/dist/ir/regexp.d.ts.map +1 -1
- package/dist/ir/regexp.js +2 -0
- package/dist/ir/types.d.ts +94 -56
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/types.js +2 -0
- package/dist/ir/validate.d.ts +8 -1
- package/dist/ir/validate.d.ts.map +1 -1
- package/dist/ir/validate.js +511 -61
- package/dist/issue/index.d.ts +42 -10
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +65 -11
- package/dist/json-schema/emit-combinator.d.ts +44 -4
- package/dist/json-schema/emit-combinator.d.ts.map +1 -1
- package/dist/json-schema/emit-combinator.js +44 -4
- package/dist/json-schema/emit-composite.d.ts +16 -2
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +81 -13
- package/dist/json-schema/emit-scalar.d.ts +26 -3
- package/dist/json-schema/emit-scalar.d.ts.map +1 -1
- package/dist/json-schema/emit-scalar.js +124 -10
- package/dist/json-schema/emit-types.d.ts +11 -1
- package/dist/json-schema/emit-types.d.ts.map +1 -1
- package/dist/json-schema/emit-types.js +2 -0
- package/dist/json-schema/emit.d.ts +12 -1
- package/dist/json-schema/emit.d.ts.map +1 -1
- package/dist/json-schema/emit.js +23 -3
- package/dist/json-schema/freeze.d.ts +13 -2
- package/dist/json-schema/freeze.d.ts.map +1 -1
- package/dist/json-schema/freeze.js +41 -8
- package/dist/json-schema/index.d.ts +16 -2
- package/dist/json-schema/index.d.ts.map +1 -1
- package/dist/json-schema/index.js +23 -3
- package/dist/json-schema/issue.d.ts +4 -1
- package/dist/json-schema/issue.d.ts.map +1 -1
- package/dist/json-schema/issue.js +4 -1
- package/dist/json-schema/read.d.ts +24 -3
- package/dist/json-schema/read.d.ts.map +1 -1
- package/dist/json-schema/read.js +59 -12
- package/dist/json-schema/types.d.ts +45 -16
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/json-schema/types.js +2 -0
- package/dist/kind/index.d.ts +40 -28
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +41 -13
- package/dist/lower/index.d.ts +6 -1
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +462 -46
- package/dist/message/index.d.ts +64 -10
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +155 -17
- package/dist/optimize/algebraic.d.ts +54 -0
- package/dist/optimize/algebraic.d.ts.map +1 -0
- package/dist/optimize/algebraic.js +314 -0
- package/dist/optimize/compact.d.ts +8 -1
- package/dist/optimize/compact.d.ts.map +1 -1
- package/dist/optimize/compact.js +13 -2
- package/dist/optimize/domain.d.ts +16 -0
- package/dist/optimize/domain.d.ts.map +1 -0
- package/dist/optimize/domain.js +619 -0
- package/dist/optimize/fold-boolean.d.ts +17 -2
- package/dist/optimize/fold-boolean.d.ts.map +1 -1
- package/dist/optimize/fold-boolean.js +59 -14
- package/dist/optimize/fold-common.d.ts +43 -8
- package/dist/optimize/fold-common.d.ts.map +1 -1
- package/dist/optimize/fold-common.js +37 -6
- package/dist/optimize/fold-constraints.d.ts +33 -0
- package/dist/optimize/fold-constraints.d.ts.map +1 -0
- package/dist/optimize/fold-constraints.js +484 -0
- package/dist/optimize/fold-scalar.d.ts +98 -13
- package/dist/optimize/fold-scalar.d.ts.map +1 -1
- package/dist/optimize/fold-scalar.js +98 -13
- package/dist/optimize/fold.d.ts +8 -1
- package/dist/optimize/fold.d.ts.map +1 -1
- package/dist/optimize/fold.js +22 -2
- package/dist/optimize/index.d.ts +9 -1
- package/dist/optimize/index.d.ts.map +1 -1
- package/dist/optimize/index.js +18 -3
- package/dist/optimize/map-node.d.ts +3 -1
- package/dist/optimize/map-node.d.ts.map +1 -1
- package/dist/optimize/map-node.js +48 -3
- package/dist/optimize/peephole.d.ts +16 -0
- package/dist/optimize/peephole.d.ts.map +1 -0
- package/dist/optimize/peephole.js +254 -0
- package/dist/optimize/remap.d.ts +2 -0
- package/dist/optimize/remap.d.ts.map +1 -1
- package/dist/optimize/remap.js +2 -0
- package/dist/optimize/rewrite.d.ts +13 -8
- package/dist/optimize/rewrite.d.ts.map +1 -1
- package/dist/optimize/rewrite.js +13 -8
- package/dist/plan/cache.d.ts +9 -3
- package/dist/plan/cache.d.ts.map +1 -1
- package/dist/plan/cache.js +34 -6
- package/dist/plan/index.d.ts +2 -0
- package/dist/plan/index.d.ts.map +1 -1
- package/dist/plan/index.js +2 -0
- package/dist/plan/predicate.d.ts +2 -0
- package/dist/plan/predicate.d.ts.map +1 -1
- package/dist/plan/predicate.js +298 -29
- package/dist/plan/schema-predicate.d.ts +6 -0
- package/dist/plan/schema-predicate.d.ts.map +1 -1
- package/dist/plan/schema-predicate.js +382 -19
- package/dist/plan/types.d.ts +2 -0
- package/dist/plan/types.d.ts.map +1 -1
- package/dist/plan/types.js +2 -0
- package/dist/result/index.d.ts +19 -5
- package/dist/result/index.d.ts.map +1 -1
- package/dist/result/index.js +10 -2
- package/dist/schema/common.d.ts +69 -6
- package/dist/schema/common.d.ts.map +1 -1
- package/dist/schema/common.js +104 -10
- package/dist/schema/freeze.d.ts +4 -0
- package/dist/schema/freeze.d.ts.map +1 -1
- package/dist/schema/freeze.js +40 -0
- package/dist/schema/index.d.ts +5 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +4 -1
- package/dist/schema/lazy.d.ts +4 -0
- package/dist/schema/lazy.d.ts.map +1 -1
- package/dist/schema/lazy.js +4 -0
- package/dist/schema/literal.d.ts +7 -1
- package/dist/schema/literal.d.ts.map +1 -1
- package/dist/schema/literal.js +7 -1
- package/dist/schema/types.d.ts +109 -100
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +13 -2
- package/dist/schema/undefined.d.ts +17 -0
- package/dist/schema/undefined.d.ts.map +1 -0
- package/dist/schema/undefined.js +77 -0
- package/dist/schema/validate.d.ts +8 -1
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +255 -57
- package/docs/api.md +128 -8
- package/docs/assets/benchmark-headline.svg +163 -0
- package/docs/engine-notes.md +62 -15
- package/docs/index.html +1340 -702
- package/docs/ko/api.md +375 -0
- package/docs/ko/engine-notes.md +156 -0
- package/docs/ko/readme.md +378 -0
- package/package.json +66 -65
package/dist/guard/string.js
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file string.ts
|
|
3
3
|
* @brief String guard implementation.
|
|
4
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
5
|
+
* existing guard instance.
|
|
4
6
|
*/
|
|
5
7
|
import { SchemaTag, StringCheckTag } from "../kind/index.js";
|
|
8
|
+
import { transform } from "../decoder/index.js";
|
|
6
9
|
import { BaseGuard } from "./base.js";
|
|
7
10
|
import { isPlainRegExp } from "./props.js";
|
|
8
11
|
import { checkStringLengthBound, readStringConstructorSchema, readStringMethodSchema } from "./read.js";
|
|
9
12
|
/**
|
|
10
|
-
* @brief string
|
|
11
|
-
* @details
|
|
12
|
-
*
|
|
13
|
+
* @brief Persistent builder for string predicates.
|
|
14
|
+
* @details Refinement methods append schema checks and return fresh frozen
|
|
15
|
+
* guards, so shared guard values cannot be mutated by later chains.
|
|
13
16
|
*/
|
|
14
17
|
export class StringGuard extends BaseGuard {
|
|
15
18
|
/**
|
|
16
|
-
* @brief
|
|
17
|
-
|
|
19
|
+
* @brief Construct a frozen string guard.
|
|
20
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
21
|
+
* existing guard instance.
|
|
22
|
+
* @param schema String schema backing this guard.
|
|
18
23
|
*/
|
|
19
24
|
constructor(schema) {
|
|
20
25
|
super(readStringConstructorSchema(schema));
|
|
21
26
|
Object.freeze(this);
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
|
-
* @brief
|
|
25
|
-
|
|
29
|
+
* @brief Add a minimum string length.
|
|
30
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
31
|
+
* existing guard instance.
|
|
32
|
+
* @param value Non-negative integer lower length bound.
|
|
33
|
+
* @returns Fresh StringGuard with an appended min check.
|
|
34
|
+
*/
|
|
26
35
|
min(value) {
|
|
27
36
|
const schema = readStringMethodSchema(this, "string min receiver");
|
|
28
37
|
const bound = checkStringLengthBound(value, "min");
|
|
@@ -38,8 +47,12 @@ export class StringGuard extends BaseGuard {
|
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
/**
|
|
41
|
-
* @brief
|
|
42
|
-
|
|
50
|
+
* @brief Add a maximum string length.
|
|
51
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
52
|
+
* existing guard instance.
|
|
53
|
+
* @param value Non-negative integer upper length bound.
|
|
54
|
+
* @returns Fresh StringGuard with an appended max check.
|
|
55
|
+
*/
|
|
43
56
|
max(value) {
|
|
44
57
|
const schema = readStringMethodSchema(this, "string max receiver");
|
|
45
58
|
const bound = checkStringLengthBound(value, "max");
|
|
@@ -55,8 +68,29 @@ export class StringGuard extends BaseGuard {
|
|
|
55
68
|
});
|
|
56
69
|
}
|
|
57
70
|
/**
|
|
58
|
-
* @brief
|
|
59
|
-
|
|
71
|
+
* @brief Require an exact string length.
|
|
72
|
+
* @param value Non-negative integer length.
|
|
73
|
+
* @returns Fresh StringGuard with matching min and max bounds.
|
|
74
|
+
*/
|
|
75
|
+
length(value) {
|
|
76
|
+
const bound = checkStringLengthBound(value, "length");
|
|
77
|
+
return this.min(bound).max(bound);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @brief Require a non-empty string.
|
|
81
|
+
* @returns Fresh StringGuard with `min(1)`.
|
|
82
|
+
*/
|
|
83
|
+
nonempty() {
|
|
84
|
+
return this.min(1);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @brief Add a regular expression check.
|
|
88
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
89
|
+
* existing guard instance.
|
|
90
|
+
* @param pattern Plain RegExp instance to clone into the schema.
|
|
91
|
+
* @param name Diagnostic name for pattern failures.
|
|
92
|
+
* @returns Fresh StringGuard with an appended regex check.
|
|
93
|
+
*/
|
|
60
94
|
regex(pattern, name) {
|
|
61
95
|
if (!isPlainRegExp(pattern)) {
|
|
62
96
|
throw new TypeError("regex pattern must be a plain RegExp");
|
|
@@ -65,6 +99,10 @@ export class StringGuard extends BaseGuard {
|
|
|
65
99
|
throw new TypeError("regex name must be a string");
|
|
66
100
|
}
|
|
67
101
|
const schema = readStringMethodSchema(this, "string regex receiver");
|
|
102
|
+
/*
|
|
103
|
+
* Clone the pattern so later mutation of lastIndex or subclass state on
|
|
104
|
+
* the caller-owned RegExp cannot affect validation.
|
|
105
|
+
*/
|
|
68
106
|
return new StringGuard({
|
|
69
107
|
tag: SchemaTag.String,
|
|
70
108
|
checks: [
|
|
@@ -78,8 +116,35 @@ export class StringGuard extends BaseGuard {
|
|
|
78
116
|
});
|
|
79
117
|
}
|
|
80
118
|
/**
|
|
81
|
-
* @brief
|
|
82
|
-
|
|
119
|
+
* @brief Require a fixed prefix.
|
|
120
|
+
* @param value Prefix string matched at offset zero.
|
|
121
|
+
* @returns Fresh StringGuard with an escaped prefix regex.
|
|
122
|
+
*/
|
|
123
|
+
startsWith(value) {
|
|
124
|
+
return this.regex(new RegExp(`^${escapeRegExpString(readStringNeedle(value, "startsWith"))}`, "u"), "starts_with");
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @brief Require a fixed suffix.
|
|
128
|
+
* @param value Suffix string matched at the end of the input.
|
|
129
|
+
* @returns Fresh StringGuard with an escaped suffix regex.
|
|
130
|
+
*/
|
|
131
|
+
endsWith(value) {
|
|
132
|
+
return this.regex(new RegExp(`${escapeRegExpString(readStringNeedle(value, "endsWith"))}$`, "u"), "ends_with");
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @brief Require a fixed substring.
|
|
136
|
+
* @param value Substring that must appear in the input.
|
|
137
|
+
* @returns Fresh StringGuard with an escaped substring regex.
|
|
138
|
+
*/
|
|
139
|
+
includes(value) {
|
|
140
|
+
return this.regex(new RegExp(escapeRegExpString(readStringNeedle(value, "includes")), "u"), "includes");
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @brief Add the built-in UUID string check.
|
|
144
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
145
|
+
* existing guard instance.
|
|
146
|
+
* @returns Fresh StringGuard with an appended uuid check.
|
|
147
|
+
*/
|
|
83
148
|
uuid() {
|
|
84
149
|
const schema = readStringMethodSchema(this, "string uuid receiver");
|
|
85
150
|
return new StringGuard({
|
|
@@ -92,4 +157,176 @@ export class StringGuard extends BaseGuard {
|
|
|
92
157
|
]
|
|
93
158
|
});
|
|
94
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* @brief Add the built-in email string check.
|
|
162
|
+
* @returns Fresh StringGuard with an appended email check.
|
|
163
|
+
*/
|
|
164
|
+
email() {
|
|
165
|
+
const schema = readStringMethodSchema(this, "string email receiver");
|
|
166
|
+
return new StringGuard({
|
|
167
|
+
tag: SchemaTag.String,
|
|
168
|
+
checks: [
|
|
169
|
+
...schema.checks,
|
|
170
|
+
{
|
|
171
|
+
tag: StringCheckTag.Email
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @brief Add the built-in URL string check.
|
|
178
|
+
* @returns Fresh StringGuard with an appended URL check.
|
|
179
|
+
* @details The check is a deterministic grammar subset rather than a
|
|
180
|
+
* throwing URL constructor call, so AOT and runtime validators agree.
|
|
181
|
+
*/
|
|
182
|
+
url() {
|
|
183
|
+
const schema = readStringMethodSchema(this, "string url receiver");
|
|
184
|
+
return new StringGuard({
|
|
185
|
+
tag: SchemaTag.String,
|
|
186
|
+
checks: [
|
|
187
|
+
...schema.checks,
|
|
188
|
+
{
|
|
189
|
+
tag: StringCheckTag.Url
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @brief Add the built-in ISO date check.
|
|
196
|
+
* @returns Fresh StringGuard with an appended ISO date check.
|
|
197
|
+
*/
|
|
198
|
+
isoDate() {
|
|
199
|
+
const schema = readStringMethodSchema(this, "string isoDate receiver");
|
|
200
|
+
return new StringGuard({
|
|
201
|
+
tag: SchemaTag.String,
|
|
202
|
+
checks: [
|
|
203
|
+
...schema.checks,
|
|
204
|
+
{
|
|
205
|
+
tag: StringCheckTag.IsoDate
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @brief Add the built-in ISO date-time check.
|
|
212
|
+
* @returns Fresh StringGuard with an appended ISO date-time check.
|
|
213
|
+
*/
|
|
214
|
+
isoDateTime() {
|
|
215
|
+
const schema = readStringMethodSchema(this, "string isoDateTime receiver");
|
|
216
|
+
return new StringGuard({
|
|
217
|
+
tag: SchemaTag.String,
|
|
218
|
+
checks: [
|
|
219
|
+
...schema.checks,
|
|
220
|
+
{
|
|
221
|
+
tag: StringCheckTag.IsoDateTime
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* @brief Add the built-in ULID string check.
|
|
228
|
+
* @returns Fresh StringGuard with an appended ULID check.
|
|
229
|
+
*/
|
|
230
|
+
ulid() {
|
|
231
|
+
const schema = readStringMethodSchema(this, "string ulid receiver");
|
|
232
|
+
return new StringGuard({
|
|
233
|
+
tag: SchemaTag.String,
|
|
234
|
+
checks: [
|
|
235
|
+
...schema.checks,
|
|
236
|
+
{
|
|
237
|
+
tag: StringCheckTag.Ulid
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @brief Add the built-in IPv4 string check.
|
|
244
|
+
* @returns Fresh StringGuard with an appended IPv4 check.
|
|
245
|
+
*/
|
|
246
|
+
ipv4() {
|
|
247
|
+
const schema = readStringMethodSchema(this, "string ipv4 receiver");
|
|
248
|
+
return new StringGuard({
|
|
249
|
+
tag: SchemaTag.String,
|
|
250
|
+
checks: [
|
|
251
|
+
...schema.checks,
|
|
252
|
+
{
|
|
253
|
+
tag: StringCheckTag.Ipv4
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* @brief Add the built-in IPv6 string check.
|
|
260
|
+
* @returns Fresh StringGuard with an appended IPv6 check.
|
|
261
|
+
*/
|
|
262
|
+
ipv6() {
|
|
263
|
+
const schema = readStringMethodSchema(this, "string ipv6 receiver");
|
|
264
|
+
return new StringGuard({
|
|
265
|
+
tag: SchemaTag.String,
|
|
266
|
+
checks: [
|
|
267
|
+
...schema.checks,
|
|
268
|
+
{
|
|
269
|
+
tag: StringCheckTag.Ipv6
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @brief Decode a string and trim surrounding whitespace.
|
|
276
|
+
* @returns Decoder that validates this string guard before trimming.
|
|
277
|
+
*/
|
|
278
|
+
trim() {
|
|
279
|
+
return transform(readRequiredStringGuard(this), (value) => trimString(value));
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* @brief Decode a string and lowercase it.
|
|
283
|
+
* @returns Decoder that validates this string guard before lowercasing.
|
|
284
|
+
*/
|
|
285
|
+
toLowerCase() {
|
|
286
|
+
return transform(readRequiredStringGuard(this), (value) => lowerString(value));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* @brief Decode a string and uppercase it.
|
|
290
|
+
* @returns Decoder that validates this string guard before uppercasing.
|
|
291
|
+
*/
|
|
292
|
+
toUpperCase() {
|
|
293
|
+
return transform(readRequiredStringGuard(this), (value) => upperString(value));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* @brief Narrow a StringGuard receiver to its runtime string contract.
|
|
298
|
+
* @param guard StringGuard receiver after method dispatch.
|
|
299
|
+
* @returns The same guard seen as a required string source for decoder transforms.
|
|
300
|
+
*/
|
|
301
|
+
function readRequiredStringGuard(guard) {
|
|
302
|
+
return guard;
|
|
303
|
+
}
|
|
304
|
+
function trimString(value) {
|
|
305
|
+
return String.prototype.trim.call(value);
|
|
306
|
+
}
|
|
307
|
+
function lowerString(value) {
|
|
308
|
+
return String.prototype.toLowerCase.call(value);
|
|
309
|
+
}
|
|
310
|
+
function upperString(value) {
|
|
311
|
+
return String.prototype.toUpperCase.call(value);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @brief Read a string argument used by fixed-string predicates.
|
|
315
|
+
* @param value Candidate substring value.
|
|
316
|
+
* @param label Method name used in thrown errors.
|
|
317
|
+
* @returns Accepted string value.
|
|
318
|
+
*/
|
|
319
|
+
function readStringNeedle(value, label) {
|
|
320
|
+
if (typeof value !== "string") {
|
|
321
|
+
throw new TypeError(`string ${label} value must be a string`);
|
|
322
|
+
}
|
|
323
|
+
return value;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* @brief Escape a literal string for RegExp source text.
|
|
327
|
+
* @param value String fragment to match literally.
|
|
328
|
+
* @returns RegExp source fragment with metacharacters escaped.
|
|
329
|
+
*/
|
|
330
|
+
function escapeRegExpString(value) {
|
|
331
|
+
return value.replace(/[\\^$.*+?()[\]{}|]/gu, "\\$&");
|
|
95
332
|
}
|
package/dist/guard/types.d.ts
CHANGED
|
@@ -1,103 +1,173 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file types.ts
|
|
3
3
|
* @brief Public guard type contracts.
|
|
4
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
5
|
+
* existing guard instance.
|
|
4
6
|
*/
|
|
5
7
|
import type { CheckResult } from "../issue/index.js";
|
|
6
8
|
import type { Graph } from "../ir/index.js";
|
|
7
9
|
import type { Schema } from "../schema/index.js";
|
|
8
10
|
import type { BaseGuard } from "./base.js";
|
|
9
|
-
/**
|
|
10
|
-
* @brief type symbol.
|
|
11
|
-
*/
|
|
12
11
|
export declare const TypeSymbol: unique symbol;
|
|
13
|
-
/**
|
|
14
|
-
* @brief presence symbol.
|
|
15
|
-
*/
|
|
16
12
|
export declare const PresenceSymbol: unique symbol;
|
|
17
|
-
/**
|
|
18
|
-
* @brief brand symbol.
|
|
19
|
-
*/
|
|
20
13
|
export declare const BrandSymbol: unique symbol;
|
|
21
14
|
/**
|
|
22
|
-
* @brief presence.
|
|
15
|
+
* @brief Object-property presence mode carried by a guard.
|
|
16
|
+
* @details Presence is a type-level property of guards, not a runtime schema
|
|
17
|
+
* wrapper by itself. Object builders use it to decide required versus optional
|
|
18
|
+
* field semantics during shape construction.
|
|
23
19
|
*/
|
|
24
20
|
export type Presence = "required" | "optional";
|
|
25
21
|
/**
|
|
26
|
-
* @brief
|
|
22
|
+
* @brief Runtime value accepted by a guard after presence is applied.
|
|
23
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
24
|
+
* existing guard instance.
|
|
27
25
|
*/
|
|
28
26
|
export type RuntimeValue<TValue, TPresence extends Presence> = TPresence extends "optional" ? TValue | undefined : TValue;
|
|
29
27
|
/**
|
|
30
|
-
* @brief
|
|
28
|
+
* @brief Infer the runtime value type accepted by a guard.
|
|
29
|
+
* @details Optional guards add undefined at the type level so object shape
|
|
30
|
+
* inference and standalone guard usage agree on accepted values.
|
|
31
31
|
*/
|
|
32
32
|
export type Infer<TGuard> = TGuard extends Guard<infer TValue, infer TPresence> ? RuntimeValue<TValue, TPresence> : never;
|
|
33
33
|
/**
|
|
34
|
-
* @brief
|
|
34
|
+
* @brief Extract the raw value type carried by a guard.
|
|
35
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
36
|
+
* existing guard instance.
|
|
35
37
|
*/
|
|
36
38
|
export type GuardValue<TGuard> = TGuard extends Guard<infer TValue, Presence> ? TValue : never;
|
|
37
39
|
/**
|
|
38
|
-
* @brief
|
|
40
|
+
* @brief Extract the presence mode carried by a guard.
|
|
41
|
+
* @details Guard helpers build new immutable schema wrappers so fluent APIs never mutate an
|
|
42
|
+
* existing guard instance.
|
|
39
43
|
*/
|
|
40
44
|
export type GuardPresence<TGuard> = TGuard extends Guard<unknown, infer TPresence> ? TPresence : never;
|
|
41
45
|
/**
|
|
42
|
-
* @brief
|
|
46
|
+
* @brief Phantom intersection used for compile-time nominal brands.
|
|
47
|
+
* @details No runtime field is materialized; validators keep the same data
|
|
48
|
+
* representation as the unbranded value.
|
|
43
49
|
*/
|
|
44
50
|
export type Brand<TValue, TBrand extends string> = TValue & {
|
|
45
51
|
readonly [BrandSymbol]: TBrand;
|
|
46
52
|
};
|
|
47
53
|
/**
|
|
48
|
-
* @brief guard.
|
|
54
|
+
* @brief Public structural guard contract.
|
|
55
|
+
* @details The symbols carry inference-only type state. The schema property is
|
|
56
|
+
* the runtime handle used by interpreters, compilers, and graph introspection.
|
|
49
57
|
*/
|
|
50
58
|
export interface Guard<TValue, TPresence extends Presence = "required"> {
|
|
51
59
|
readonly [TypeSymbol]: TValue;
|
|
52
60
|
readonly [PresenceSymbol]: TPresence;
|
|
53
61
|
readonly schema: Schema;
|
|
54
62
|
/**
|
|
55
|
-
* @brief is.
|
|
56
|
-
|
|
63
|
+
* @brief Test whether a runtime value is accepted.
|
|
64
|
+
* @details This is the boolean hot path. It avoids diagnostic allocation and
|
|
65
|
+
* is the method used by compiled predicates for tight validation loops.
|
|
66
|
+
* @param value Candidate runtime value.
|
|
67
|
+
* @returns True when the guard accepts the value.
|
|
68
|
+
*/
|
|
57
69
|
is(value: unknown): value is RuntimeValue<TValue, TPresence>;
|
|
58
70
|
/**
|
|
59
|
-
* @brief
|
|
60
|
-
|
|
71
|
+
* @brief Validate a runtime value and return explicit issues on failure.
|
|
72
|
+
* @details Use this path when callers need structured diagnostics. Success
|
|
73
|
+
* returns the original value with the guard's inferred runtime type.
|
|
74
|
+
* @param value Candidate runtime value.
|
|
75
|
+
* @returns Check result with either the accepted value or frozen issues.
|
|
76
|
+
*/
|
|
61
77
|
check(value: unknown): CheckResult<RuntimeValue<TValue, TPresence>>;
|
|
62
78
|
/**
|
|
63
|
-
* @brief
|
|
64
|
-
|
|
79
|
+
* @brief Validate a runtime value and keep only the first issue.
|
|
80
|
+
* @details This diagnostic path is intended for hot rejection checks where
|
|
81
|
+
* callers need one machine-readable failure and do not want full-tree issue
|
|
82
|
+
* collection. Success returns the original value with the guard's inferred type.
|
|
83
|
+
* @param value Candidate runtime value.
|
|
84
|
+
* @returns Check result with at most one frozen issue on failure.
|
|
85
|
+
*/
|
|
86
|
+
checkFirst(value: unknown): CheckResult<RuntimeValue<TValue, TPresence>>;
|
|
87
|
+
/**
|
|
88
|
+
* @brief Validate a runtime value or throw TypeSeaAssertionError.
|
|
89
|
+
* @details This convenience wrapper is intentionally explicit in the method
|
|
90
|
+
* name because most TypeSea APIs prefer Result-based control flow.
|
|
91
|
+
* @param value Candidate runtime value.
|
|
92
|
+
*/
|
|
65
93
|
assert(value: unknown): asserts value is RuntimeValue<TValue, TPresence>;
|
|
66
94
|
/**
|
|
67
|
-
* @brief graph.
|
|
68
|
-
|
|
95
|
+
* @brief Return the optimized validation graph for introspection.
|
|
96
|
+
* @details The graph is immutable and may be reused by tooling, debugging,
|
|
97
|
+
* or code generation without exposing schema internals directly.
|
|
98
|
+
* @returns Optimized Sea-of-Nodes validation graph.
|
|
99
|
+
*/
|
|
69
100
|
graph(): Graph;
|
|
70
101
|
/**
|
|
71
|
-
* @brief optional.
|
|
72
|
-
|
|
102
|
+
* @brief Mark this guard optional for object shape usage.
|
|
103
|
+
* @details Optionality changes object field presence and standalone
|
|
104
|
+
* inference by adding undefined; it does not mutate the source guard.
|
|
105
|
+
* @returns New guard carrying optional presence.
|
|
106
|
+
*/
|
|
73
107
|
optional(): BaseGuard<TValue, "optional">;
|
|
74
108
|
/**
|
|
75
|
-
* @brief
|
|
76
|
-
|
|
109
|
+
* @brief Allow the explicit undefined value.
|
|
110
|
+
* @details This widens the value domain while preserving the field presence
|
|
111
|
+
* mode. In object shapes, an undefinedable required field still has to be
|
|
112
|
+
* present.
|
|
113
|
+
* @returns New guard whose value type includes undefined.
|
|
114
|
+
*/
|
|
77
115
|
undefinedable(): BaseGuard<TValue | undefined, TPresence>;
|
|
78
116
|
/**
|
|
79
|
-
* @brief
|
|
80
|
-
|
|
117
|
+
* @brief Allow the explicit null value.
|
|
118
|
+
* @details Nullability is modeled as a value-domain wrapper rather than an
|
|
119
|
+
* object-presence change, so it composes predictably with optional fields.
|
|
120
|
+
* @returns New guard whose value type includes null.
|
|
121
|
+
*/
|
|
81
122
|
nullable(): BaseGuard<TValue | null, TPresence>;
|
|
82
123
|
/**
|
|
83
|
-
* @brief array.
|
|
84
|
-
|
|
124
|
+
* @brief Build an array guard from this guard.
|
|
125
|
+
* @details The item schema is the current guard's runtime value domain after
|
|
126
|
+
* presence has been applied, matching direct `is` semantics.
|
|
127
|
+
* @returns Guard that accepts arrays of values accepted by this guard.
|
|
128
|
+
*/
|
|
85
129
|
array(): BaseGuard<RuntimeValue<TValue, TPresence>[]>;
|
|
86
130
|
/**
|
|
87
|
-
* @brief brand.
|
|
88
|
-
|
|
131
|
+
* @brief Apply a compile-time brand without changing runtime data.
|
|
132
|
+
* @details Brands are phantom types. Validation behavior and emitted IR stay
|
|
133
|
+
* identical to the unbranded guard.
|
|
134
|
+
* @returns New guard carrying the requested nominal brand.
|
|
135
|
+
*/
|
|
89
136
|
brand<TBrand extends string>(): BaseGuard<Brand<TValue, TBrand>, TPresence>;
|
|
90
137
|
/**
|
|
91
|
-
* @brief
|
|
92
|
-
|
|
138
|
+
* @brief Append a user refinement predicate.
|
|
139
|
+
* @details Refinements run after the base schema accepts the value. They are
|
|
140
|
+
* intentionally opaque to JSON Schema and AOT export because the predicate is
|
|
141
|
+
* arbitrary user code.
|
|
142
|
+
* @param predicate Function that returns literal true for success.
|
|
143
|
+
* @param name Diagnostic name for failed refinements.
|
|
144
|
+
* @returns New guard with the refinement appended.
|
|
145
|
+
*/
|
|
93
146
|
refine(predicate: (value: RuntimeValue<TValue, TPresence>) => boolean, name: string): BaseGuard<TValue, TPresence>;
|
|
94
147
|
/**
|
|
95
|
-
* @brief
|
|
96
|
-
|
|
148
|
+
* @brief Build a union with another guard.
|
|
149
|
+
* @details Union order is preserved so diagnostics and generated code follow
|
|
150
|
+
* the same branch precedence as the fluent call chain.
|
|
151
|
+
* @param other Guard accepted as the second union arm.
|
|
152
|
+
* @returns Guard accepting values accepted by either guard.
|
|
153
|
+
*/
|
|
97
154
|
or<TOther extends Guard<unknown, Presence>>(other: TOther): BaseGuard<RuntimeValue<TValue, TPresence> | Infer<TOther>>;
|
|
98
155
|
/**
|
|
99
|
-
* @brief
|
|
100
|
-
|
|
156
|
+
* @brief Build an intersection with another guard.
|
|
157
|
+
* @details Both guards must accept the same value. The resulting type is the
|
|
158
|
+
* TypeScript intersection of their inferred runtime domains.
|
|
159
|
+
* @param other Guard accepted as the second intersection arm.
|
|
160
|
+
* @returns Guard accepting only values accepted by both guards.
|
|
161
|
+
*/
|
|
101
162
|
intersect<TOther extends Guard<unknown, Presence>>(other: TOther): BaseGuard<RuntimeValue<TValue, TPresence> & Infer<TOther>>;
|
|
163
|
+
/**
|
|
164
|
+
* @brief Require one own data property after this guard succeeds.
|
|
165
|
+
* @details This is a safe property proof: only own data descriptors are
|
|
166
|
+
* accepted, so validation does not execute getters.
|
|
167
|
+
* @param key Own string property key to inspect.
|
|
168
|
+
* @param value Guard applied to the property value.
|
|
169
|
+
* @returns Guard carrying the base type plus the property proof.
|
|
170
|
+
*/
|
|
171
|
+
property<const TKey extends string, TGuard extends Guard<unknown, Presence>>(key: TKey, value: TGuard): BaseGuard<RuntimeValue<TValue, TPresence> & Readonly<Record<TKey, Infer<TGuard>>>>;
|
|
102
172
|
}
|
|
103
173
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/guard/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/guard/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,OAAO,CAAC,MAAM,UAAU,EAAE,OAAO,MAAM,CAAC;AAE/C,MAAM,CAAC,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAEnD,MAAM,CAAC,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CA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AK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,SAAS,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC7C,KAAK,EAAE,MAAM,GACd,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9D;;;;;;;OAOG;IACH,QAAQ,CACJ,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,MAAM,SAAS,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAEvC,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,GACd,SAAS,CACR,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAC1E,CAAC;CACL"}
|
package/dist/guard/types.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { t, array, bigintGuard, discriminatedUnion, extend, intersect, lazy, literal, nullable, neverGuard, object, omit, optional, partial, pick, record, refine, strictObject, symbolGuard, tuple, union, unknownGuard, undefinedable, type InferObject, type InferTuple, type MergeObjectShapes, type ObjectGuardMode, type ObjectShape, type OmitObjectShape, ObjectGuard, type PartialObjectShape, type PickObjectShape, type TupleShape } from "./builders/index.js";
|
|
2
|
-
export { BaseGuard, NumberGuard, StringGuard, TypeSeaAssertionError, type Brand, type Guard, type GuardPresence, type GuardValue, type Infer, type Presence, type RuntimeValue } from "./guard/index.js";
|
|
3
|
-
export { CompiledBaseGuard, compile, type CompileOptions, type CompiledGuard } from "./compile/index.js";
|
|
1
|
+
export { t, array, bigintGuard, catchall, dateGuard, deepPartial, discriminatedUnion, enum, enumValues, extend, instanceOf, intersect, json, lazy, literal, map, merge, nullable, neverGuard, nullGuard, nullish, object, omit, optional, partial, passthrough, pick, property, record, refine, required, safeExtend, set, strict, strictObject, strip, symbolGuard, tuple, union, unknownGuard, undefinedGuard, undefinedable, voidGuard, type DeepPartialObjectShape, type DeepPartialValue, type InferObject, type InferTuple, type InferTupleWithRest, type EnumValues, type InstanceConstructor, type JsonValue, type MaskSelectedKeys, type MergeObjectShapes, type ObjectKeyMask, type ObjectGuardMode, type ObjectShape, type OmitObjectShape, type OmitObjectShapeByMask, ObjectGuard, type PartialObjectShape, type PickObjectShape, type PickObjectShapeByMask, type RequiredObjectShape, type TupleShape } from "./builders/index.js";
|
|
2
|
+
export { BaseGuard, ArrayGuard, DateGuard, NumberGuard, StringGuard, TypeSeaAssertionError, type Brand, type Guard, type GuardPresence, type GuardValue, type Infer, type Presence, type RuntimeValue } from "./guard/index.js";
|
|
3
|
+
export { CompiledBaseGuard, compile, type CompileMode, type CompileOptions, type CompiledGuard } from "./compile/index.js";
|
|
4
4
|
export { emitAotModule, type AotCompileOptions, type AotIssue, type AotIssueCode, type AotModule } from "./aot/index.js";
|
|
5
5
|
export { toAsyncTrpcParser, toFastifyRouteSchema, toFastifyValidatorCompiler, toReactHookFormResolver, toTrpcParser, type AsyncTrpcParser, type FastifyHttpPart, type FastifyRouteSchema, type FastifyRouteSchemaOptions, type FastifyValidationResult, type FastifyValidator, type FastifyValidatorCompiler, type FastifyValidatorCompilerSource, type FastifyValidatorCompilerSourceMap, type FastifyValidatorRoute, type InferAdapter, type InferSyncAdapter, type ReactHookFormErrors, type ReactHookFormFieldError, type ReactHookFormResolver, type ReactHookFormResolverOptions, type ReactHookFormResolverResult, type SyncAdapterSource, type TrpcParser } from "./adapters/index.js";
|
|
6
6
|
export { BaseAsyncDecoder, asyncDecoder, asyncPipe, asyncRefine, asyncTransform, isAsyncDecoderValue, type AsyncDecodeSource, type AsyncDecoder, type InferAsyncDecoder } from "./async/index.js";
|
|
7
|
-
export { BaseDecoder, coerce, coerceBoolean, coerceNumber, coerceString, decoder, isDecoderValue, pipe, transform, type DecodeSource, type Decoder, type InferDecoder } from "./decoder/index.js";
|
|
7
|
+
export { BaseCodec, BaseDecoder, catchValue, codec, coerce, coerceBoolean, coerceNumber, coerceString, defaultValue, decoder, isCodecValue, isDecoderValue, pipe, prefault, transform, type Codec, type DecodeSource, type Decoder, type InferDecoder } from "./decoder/index.js";
|
|
8
8
|
export { schemaToJsonSchema, toJsonSchema, type JsonSchema, type JsonSchemaExportCode, type JsonSchemaExportIssue, type JsonSchemaObject, type JsonSchemaOptions, type JsonSchemaPrimitive, type JsonSchemaTypeName } from "./json-schema/index.js";
|
|
9
|
-
export { defineMessages, formatIssue, formatIssues, withMessages, type IssueMessageCatalog, type IssueMessageContext, type IssueMessageFormatter, type IssueMessageOptions, type IssueMessageTemplate, type MessageLocale } from "./message/index.js";
|
|
9
|
+
export { defineMessages, flattenIssues, formatIssue, formatIssues, withMessages, type FlattenedIssueMessages, type IssueMessageCatalog, type IssueMessageContext, type IssueMessageFormatter, type IssueMessageOptions, type IssueMessageTemplate, type MessageLocale } from "./message/index.js";
|
|
10
10
|
export type { CheckResult, Issue, IssueCode, PathSegment } from "./issue/index.js";
|
|
11
11
|
export type { Graph, GraphNode, NodeId } from "./ir/index.js";
|
|
12
12
|
export { optimizeGraph } from "./optimize/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,CAAC,EACD,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,GAAG,EACH,KAAK,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,QAA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aAAa,EACrB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnF,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { t, array, bigintGuard, discriminatedUnion, extend, intersect, lazy, literal, nullable, neverGuard, object, omit, optional, partial, pick, record, refine, strictObject, symbolGuard, tuple, union, unknownGuard, undefinedable, ObjectGuard } from "./builders/index.js";
|
|
2
|
-
export { BaseGuard, NumberGuard, StringGuard, TypeSeaAssertionError } from "./guard/index.js";
|
|
1
|
+
export { t, array, bigintGuard, catchall, dateGuard, deepPartial, discriminatedUnion, enum, enumValues, extend, instanceOf, intersect, json, lazy, literal, map, merge, nullable, neverGuard, nullGuard, nullish, object, omit, optional, partial, passthrough, pick, property, record, refine, required, safeExtend, set, strict, strictObject, strip, symbolGuard, tuple, union, unknownGuard, undefinedGuard, undefinedable, voidGuard, ObjectGuard } from "./builders/index.js";
|
|
2
|
+
export { BaseGuard, ArrayGuard, DateGuard, NumberGuard, StringGuard, TypeSeaAssertionError } from "./guard/index.js";
|
|
3
3
|
export { CompiledBaseGuard, compile } from "./compile/index.js";
|
|
4
4
|
export { emitAotModule } from "./aot/index.js";
|
|
5
5
|
export { toAsyncTrpcParser, toFastifyRouteSchema, toFastifyValidatorCompiler, toReactHookFormResolver, toTrpcParser } from "./adapters/index.js";
|
|
6
6
|
export { BaseAsyncDecoder, asyncDecoder, asyncPipe, asyncRefine, asyncTransform, isAsyncDecoderValue } from "./async/index.js";
|
|
7
|
-
export { BaseDecoder, coerce, coerceBoolean, coerceNumber, coerceString, decoder, isDecoderValue, pipe, transform } from "./decoder/index.js";
|
|
7
|
+
export { BaseCodec, BaseDecoder, catchValue, codec, coerce, coerceBoolean, coerceNumber, coerceString, defaultValue, decoder, isCodecValue, isDecoderValue, pipe, prefault, transform } from "./decoder/index.js";
|
|
8
8
|
export { schemaToJsonSchema, toJsonSchema } from "./json-schema/index.js";
|
|
9
|
-
export { defineMessages, formatIssue, formatIssues, withMessages } from "./message/index.js";
|
|
9
|
+
export { defineMessages, flattenIssues, formatIssue, formatIssues, withMessages } from "./message/index.js";
|
|
10
10
|
export { optimizeGraph } from "./optimize/index.js";
|