typesea 0.1.0 → 0.2.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 +67 -6
- package/README.md +98 -17
- 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 +18 -2
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +93 -14
- 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 +37 -6
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +84 -10
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +2 -0
- package/dist/builders/modifier.d.ts +30 -5
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +38 -5
- package/dist/builders/object/guard.d.ts +18 -22
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +26 -26
- package/dist/builders/object/index.d.ts +2 -0
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +2 -0
- package/dist/builders/object/schema.d.ts +55 -9
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +92 -15
- package/dist/builders/object/types.d.ts +5 -31
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/object/types.js +2 -0
- package/dist/builders/scalar.d.ts +29 -8
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +33 -8
- package/dist/builders/table.d.ts +4 -0
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +4 -0
- package/dist/builders/types.d.ts +14 -4
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/builders/types.js +2 -0
- package/dist/compile/check-composite.d.ts +22 -1
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +564 -24
- package/dist/compile/check-scalar.d.ts +78 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +432 -1
- package/dist/compile/check.d.ts +12 -0
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +37 -0
- package/dist/compile/context.d.ts +47 -9
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +51 -8
- 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 +1907 -171
- package/dist/compile/guard.d.ts +15 -24
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +158 -74
- 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 +131 -5
- package/dist/compile/runtime.d.ts +80 -12
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +25 -6
- package/dist/compile/source.d.ts +10 -2
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +361 -26
- package/dist/compile/types.d.ts +20 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/compile/types.js +2 -0
- package/dist/decoder/index.d.ts +32 -46
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +102 -38
- package/dist/evaluate/check-composite.d.ts +59 -0
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +151 -3
- package/dist/evaluate/check-scalar.d.ts +16 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +32 -0
- package/dist/evaluate/check.d.ts +7 -0
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +43 -0
- 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 +59 -13
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +66 -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/base.d.ts +79 -29
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +91 -29
- 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 +2 -0
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -0
- package/dist/guard/number.d.ts +26 -11
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +30 -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 +62 -9
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +83 -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 +33 -13
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +37 -13
- package/dist/guard/types.d.ts +92 -40
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/types.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- 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 +16 -126
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +77 -137
- package/dist/ir/freeze.d.ts +4 -0
- package/dist/ir/freeze.d.ts.map +1 -1
- package/dist/ir/freeze.js +59 -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 +90 -55
- 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 +477 -61
- package/dist/issue/index.d.ts +41 -9
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +61 -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 +10 -0
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +15 -1
- 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 +70 -9
- 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 +12 -1
- 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 +38 -15
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/json-schema/types.js +2 -0
- package/dist/kind/index.d.ts +15 -28
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +15 -10
- package/dist/lower/index.d.ts +6 -1
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +411 -44
- package/dist/message/index.d.ts +46 -10
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +88 -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 +615 -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 +45 -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 +21 -5
- 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 +268 -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 +117 -13
- 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 +18 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +3 -0
- 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 +20 -96
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +5 -1
- package/dist/schema/undefined.d.ts +17 -0
- package/dist/schema/undefined.d.ts.map +1 -0
- package/dist/schema/undefined.js +72 -0
- package/dist/schema/validate.d.ts +8 -1
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +146 -55
- package/docs/api.md +57 -0
- package/docs/assets/benchmark-headline.svg +163 -0
- package/docs/engine-notes.md +58 -15
- package/docs/index.html +130 -110
- package/package.json +65 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,70 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
All notable changes to TypeSea are recorded here.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
## 0.2.0 - 2026-07-04
|
|
6
|
+
|
|
7
|
+
Initial public release of TypeSea: a zero-runtime-dependency TypeScript runtime
|
|
8
|
+
narrowing library built around immutable guards, optimized Sea-of-Nodes
|
|
9
|
+
validation plans, runtime compilation, and AOT source generation.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added the `t` builder surface for scalar, object, strict object, array,
|
|
14
|
+
tuple, record, union, discriminated union, intersection, optional,
|
|
15
|
+
undefinedable, nullable, literal, brand, refine, lazy, unknown, and never
|
|
16
|
+
guards.
|
|
17
|
+
- Added `is()`, `check()`, and `assert()` guard APIs with explicit Result-style
|
|
18
|
+
diagnostics and frozen public outputs.
|
|
19
|
+
- Added `compile()` for runtime-generated validators and `emitAotModule()` for
|
|
20
|
+
standalone validator source.
|
|
21
|
+
- Added safe, unsafe, and unchecked compile modes. Safe mode keeps hostile-input
|
|
22
|
+
descriptor semantics by default; unsafe and unchecked modes opt into
|
|
23
|
+
trusted-data FastMode codegen.
|
|
24
|
+
- Added optimized Sea-of-Nodes validation plans, graph introspection, constant
|
|
25
|
+
folding, algebraic simplification, peephole optimization, and
|
|
26
|
+
validation-domain specialization for composite loops.
|
|
27
|
+
- Added lossless JSON Schema export with typed issues for unsupported runtime
|
|
28
|
+
semantics.
|
|
29
|
+
- Added adapters for tRPC, async tRPC-style parsers, Fastify route schemas,
|
|
30
|
+
Fastify validator compilers, and React Hook Form resolvers.
|
|
31
|
+
- Added seeded parity fuzzing across runtime plan, compiled validators, AOT
|
|
32
|
+
output, sparse arrays, accessors, symbol keys, non-enumerable extras, and
|
|
33
|
+
FastMode trusted-data invariants.
|
|
34
|
+
- Added release gates for source policy, docs validation, typechecking, linting,
|
|
35
|
+
tests, dist policy, public API drift, package contents, consumer smoke tests,
|
|
36
|
+
and benchmark smoke coverage.
|
|
37
|
+
|
|
38
|
+
### Performance
|
|
39
|
+
|
|
40
|
+
- Measured TypeSea compiled safe `is()` at `4,297,306 hz` on valid benchmark
|
|
41
|
+
objects, essentially Ajv-class throughput while keeping TypeSea's hostile
|
|
42
|
+
boundary contract.
|
|
43
|
+
- Measured TypeSea compiled unsafe `is()` at `36,297,653 hz` and unchecked
|
|
44
|
+
`is()` at `42,581,174 hz` on valid benchmark objects.
|
|
45
|
+
- Measured TypeSea compiled safe invalid `is()` at `42,080,241 hz`, ahead of
|
|
46
|
+
Ajv on the local strict-object benchmark run.
|
|
47
|
+
- Measured TypeSea compiled safe invalid `check()` at `2,086,129 hz`, with
|
|
48
|
+
unsafe and unchecked diagnostic modes at `3,077,367 hz` and `3,673,508 hz`.
|
|
49
|
+
|
|
50
|
+
### Security And Correctness
|
|
51
|
+
|
|
52
|
+
- Enforced zero runtime dependencies, strict TypeScript settings, no `any`, and
|
|
53
|
+
no expected-failure exceptions through policy gates.
|
|
54
|
+
- Kept safe validation getter-free by using property descriptors for hostile
|
|
55
|
+
boundary data.
|
|
56
|
+
- Rejected strict-object symbol and non-enumerable extras in safe mode.
|
|
57
|
+
- Fixed strict object compiled/AOT parity around own-key counting and required
|
|
58
|
+
non-enumerable properties.
|
|
59
|
+
- Fixed interpreter step-budget divergence on large valid arrays by making the
|
|
60
|
+
limit configurable and parity-covered.
|
|
61
|
+
- Fixed React Hook Form nested error output and Fastify validator compiler
|
|
62
|
+
route-part handling.
|
|
63
|
+
- Fixed unsafe optional own-`undefined` field codegen so child guard refinements
|
|
64
|
+
cannot leak between generated branches.
|
|
65
|
+
|
|
66
|
+
### Packaging
|
|
67
|
+
|
|
68
|
+
- Published as ESM-only with Node.js `>=20.19`.
|
|
69
|
+
- Added repository metadata, package export defaults, docs site checks, CI
|
|
70
|
+
matrices, Pages deployment workflow, and npm publish workflow support.
|
package/README.md
CHANGED
|
@@ -11,6 +11,19 @@
|
|
|
11
11
|
built around **immutable guards**, optimized **Sea-of-Nodes validation plans**,
|
|
12
12
|
runtime compilation, and AOT source generation.
|
|
13
13
|
|
|
14
|
+
## Benchmark Headline
|
|
15
|
+
|
|
16
|
+
Last local benchmark on 2026-07-04 KST:
|
|
17
|
+
`npm run bench -- bench/ecosystem.bench.ts --run`, strict-object contract,
|
|
18
|
+
operations per second on one machine.
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
TypeSea safe compiled validators are already in Ajv's boolean hot-path class
|
|
23
|
+
while keeping descriptor-based hostile-input semantics. Unsafe and unchecked
|
|
24
|
+
FastMode are the bragging-rights path for trusted normalized data: direct field
|
|
25
|
+
loads, allocation-light strict-key loops, and V8-friendly monomorphic codegen.
|
|
26
|
+
|
|
14
27
|
> Goal: not "probably valid", but **provably parity-tested validation** that
|
|
15
28
|
> never executes user code, never throws on expected failures, and never leaks
|
|
16
29
|
> mutable state across a public boundary.
|
|
@@ -110,6 +123,47 @@ schema is hot enough to deserve generated validator code.
|
|
|
110
123
|
> environments, generate validator source ahead of time with
|
|
111
124
|
> `emitAotModule()` instead.
|
|
112
125
|
|
|
126
|
+
### Unsafe FastMode
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const FastButLooseUser = compile(User, {
|
|
130
|
+
name: "isUserFast",
|
|
131
|
+
mode: "unsafe"
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const FastTrustedShapeUser = compile(User, {
|
|
135
|
+
name: "isUserTrustedShape",
|
|
136
|
+
mode: "unchecked"
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`compile(..., { mode: "unsafe" })` and
|
|
141
|
+
`emitAotModule(..., { mode: "unsafe" })` emit the V8-friendliest predicate
|
|
142
|
+
TypeSea can generate: required object fields are read with direct bracket
|
|
143
|
+
access, arrays and tuples use direct indexed loads, discriminants avoid
|
|
144
|
+
descriptor reads, and strict-object extras are checked with an allocation-free
|
|
145
|
+
`for...in` loop. This mode is for trusted, already-normalized data on extremely
|
|
146
|
+
hot paths.
|
|
147
|
+
|
|
148
|
+
The default is still `mode: "safe"`. Unsafe mode may execute getters, may accept
|
|
149
|
+
prototype-backed values, and strict objects do not reject symbol or
|
|
150
|
+
non-enumerable extras. Use it only when the caller owns the object graph or has
|
|
151
|
+
already normalized input into plain data records. Unsafe generated predicates
|
|
152
|
+
may also embed escaped static property keys directly in source so V8 can use
|
|
153
|
+
ordinary property-load inline caches.
|
|
154
|
+
|
|
155
|
+
`mode: "unchecked"` goes one step further: it trusts the object shape and skips
|
|
156
|
+
strict extra-key loops entirely. That is the fastest path for already-owned DTOs,
|
|
157
|
+
but strict objects no longer reject any extra keys.
|
|
158
|
+
|
|
159
|
+
In unsafe and unchecked modes, successful compiled `check()` calls return a raw
|
|
160
|
+
`{ ok: true, value }` object instead of freezing the success result. Failed
|
|
161
|
+
diagnostics are still frozen. Safe mode keeps the fully frozen Result contract.
|
|
162
|
+
FastMode diagnostic collectors also use the same trusted direct-read object
|
|
163
|
+
shape where possible, so their issue codes can be less hostile-input-specific
|
|
164
|
+
than safe mode for missing/accessor-backed fields and sparse/accessor-backed
|
|
165
|
+
array or record slots. Discriminant diagnostics also read tags directly.
|
|
166
|
+
|
|
113
167
|
---
|
|
114
168
|
|
|
115
169
|
## Presence Semantics
|
|
@@ -159,29 +213,56 @@ failed check() -> schema-aware diagnostic collector
|
|
|
159
213
|
|
|
160
214
|
## Performance Snapshot
|
|
161
215
|
|
|
162
|
-
Last local
|
|
163
|
-
`npm run
|
|
164
|
-
operations per second on one machine, not release
|
|
216
|
+
Last local benchmark on 2026-07-04 KST, using
|
|
217
|
+
`npm run bench -- bench/ecosystem.bench.ts --run` on the benchmark strict-object
|
|
218
|
+
contract. These are operations per second on one machine, not release
|
|
219
|
+
guarantees.
|
|
165
220
|
|
|
166
221
|
| Valid object path | hz |
|
|
167
222
|
| --- | ---: |
|
|
168
|
-
| TypeSea interpreted `is()` |
|
|
169
|
-
| TypeSea compiled `is()` | 4,
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
223
|
+
| TypeSea interpreted `is()` | 513,701 |
|
|
224
|
+
| TypeSea compiled safe `is()` | 4,297,306 |
|
|
225
|
+
| TypeSea compiled unsafe `is()` | 36,297,653 |
|
|
226
|
+
| TypeSea compiled unchecked `is()` | 42,581,174 |
|
|
227
|
+
| Zod `safeParse` | 1,343,756 |
|
|
228
|
+
| Valibot `safeParse` | 1,406,528 |
|
|
229
|
+
| Ajv compiled | 4,275,389 |
|
|
230
|
+
|
|
231
|
+
| Valid diagnostic path | hz |
|
|
232
|
+
| --- | ---: |
|
|
233
|
+
| TypeSea interpreted `check()` | 503,232 |
|
|
234
|
+
| TypeSea compiled safe `check()` | 3,903,929 |
|
|
235
|
+
| TypeSea compiled unsafe `check()` | 35,568,425 |
|
|
236
|
+
| TypeSea compiled unchecked `check()` | 40,084,605 |
|
|
237
|
+
| Zod `safeParse` | 1,355,014 |
|
|
238
|
+
| Valibot `safeParse` | 1,378,266 |
|
|
239
|
+
| Ajv compiled | 4,278,587 |
|
|
173
240
|
|
|
174
241
|
| Invalid object path | hz |
|
|
175
242
|
| --- | ---: |
|
|
176
|
-
| TypeSea interpreted `is()` | 3,
|
|
177
|
-
| TypeSea compiled `is()` |
|
|
178
|
-
|
|
|
179
|
-
|
|
|
180
|
-
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
243
|
+
| TypeSea interpreted `is()` | 3,636,369 |
|
|
244
|
+
| TypeSea compiled safe `is()` | 42,080,241 |
|
|
245
|
+
| TypeSea compiled unsafe `is()` | 49,654,076 |
|
|
246
|
+
| TypeSea compiled unchecked `is()` | 50,482,732 |
|
|
247
|
+
| Zod `safeParse` | 84,272 |
|
|
248
|
+
| Valibot `safeParse` | 878,521 |
|
|
249
|
+
| Ajv compiled | 27,820,643 |
|
|
250
|
+
|
|
251
|
+
| Invalid diagnostic path | hz |
|
|
252
|
+
| --- | ---: |
|
|
253
|
+
| TypeSea interpreted `check()` | 420,446 |
|
|
254
|
+
| TypeSea compiled safe `check()` | 2,086,129 |
|
|
255
|
+
| TypeSea compiled unsafe `check()` | 3,077,367 |
|
|
256
|
+
| TypeSea compiled unchecked `check()` | 3,673,508 |
|
|
257
|
+
| Zod `safeParse` | 79,613 |
|
|
258
|
+
| Valibot `safeParse` | 887,991 |
|
|
259
|
+
| Ajv compiled | 28,713,035 |
|
|
260
|
+
|
|
261
|
+
The safe compiled path stays close to Ajv while retaining TypeSea hostile-input
|
|
262
|
+
semantics: descriptor-based property reads, symbol/non-enumerable strict-key
|
|
263
|
+
rejection, presence semantics, immutable diagnostics, and TypeScript guard
|
|
264
|
+
inference. Unsafe and unchecked compiled modes are faster because they
|
|
265
|
+
deliberately give up parts of that hostile-input contract.
|
|
185
266
|
|
|
186
267
|
---
|
|
187
268
|
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -6,30 +6,42 @@ import type { Result } from "../result/index.js";
|
|
|
6
6
|
import { type JsonSchema, type JsonSchemaDialect, type JsonSchemaExportIssue } from "../json-schema/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* @brief sync adapter source.
|
|
9
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
10
|
+
* adding framework dependencies.
|
|
9
11
|
*/
|
|
10
12
|
export type SyncAdapterSource = DecodeSource;
|
|
11
13
|
/**
|
|
12
14
|
* @brief infer sync adapter.
|
|
15
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
16
|
+
* adding framework dependencies.
|
|
13
17
|
*/
|
|
14
18
|
export type InferSyncAdapter<TSource> = InferDecoder<TSource>;
|
|
15
19
|
/**
|
|
16
20
|
* @brief infer adapter.
|
|
21
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
22
|
+
* adding framework dependencies.
|
|
17
23
|
*/
|
|
18
24
|
export type InferAdapter<TSource> = InferAsyncDecoder<TSource>;
|
|
19
25
|
/**
|
|
20
26
|
* @brief trpc parser.
|
|
27
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
28
|
+
* adding framework dependencies.
|
|
21
29
|
*/
|
|
22
30
|
export interface TrpcParser<TValue> {
|
|
23
31
|
readonly parse: (value: unknown) => TValue;
|
|
24
32
|
}
|
|
25
33
|
/**
|
|
26
34
|
* @brief async trpc parser.
|
|
35
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
36
|
+
* adding framework dependencies.
|
|
27
37
|
*/
|
|
28
38
|
export interface AsyncTrpcParser<TValue> {
|
|
29
39
|
readonly parseAsync: (value: unknown) => Promise<TValue>;
|
|
30
40
|
}
|
|
31
41
|
/**
|
|
32
42
|
* @brief fastify route schema.
|
|
43
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
44
|
+
* adding framework dependencies.
|
|
33
45
|
*/
|
|
34
46
|
export interface FastifyRouteSchema {
|
|
35
47
|
readonly body?: JsonSchema;
|
|
@@ -40,28 +52,34 @@ export interface FastifyRouteSchema {
|
|
|
40
52
|
}
|
|
41
53
|
/**
|
|
42
54
|
* @brief fastify http part.
|
|
55
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
56
|
+
* adding framework dependencies.
|
|
43
57
|
*/
|
|
44
58
|
export type FastifyHttpPart = "body" | "querystring" | "params" | "headers";
|
|
45
59
|
/**
|
|
46
60
|
* @brief fastify route schema options.
|
|
61
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
62
|
+
* adding framework dependencies.
|
|
47
63
|
*/
|
|
48
64
|
export interface FastifyRouteSchemaOptions {
|
|
49
65
|
readonly part: FastifyHttpPart;
|
|
50
66
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
* @brief schema id.
|
|
68
|
+
* @details Forwards a concrete `$schema` marker to the JSON Schema exporter.
|
|
69
|
+
* @invariant When omitted, TypeSea emits its conservative default dialect marker.
|
|
70
|
+
*/
|
|
55
71
|
readonly schemaId?: string;
|
|
56
72
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
* @brief dialect.
|
|
74
|
+
* @details Selects the JSON Schema keyword set used by generated route schemas.
|
|
75
|
+
* @invariant Tuple schemas remain validator-visible for the selected dialect.
|
|
76
|
+
*/
|
|
61
77
|
readonly dialect?: JsonSchemaDialect;
|
|
62
78
|
}
|
|
63
79
|
/**
|
|
64
80
|
* @brief fastify validator route.
|
|
81
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
82
|
+
* adding framework dependencies.
|
|
65
83
|
*/
|
|
66
84
|
export interface FastifyValidatorRoute {
|
|
67
85
|
readonly schema: unknown;
|
|
@@ -71,6 +89,8 @@ export interface FastifyValidatorRoute {
|
|
|
71
89
|
}
|
|
72
90
|
/**
|
|
73
91
|
* @brief fastify validation result.
|
|
92
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
93
|
+
* adding framework dependencies.
|
|
74
94
|
*/
|
|
75
95
|
export type FastifyValidationResult = {
|
|
76
96
|
readonly value: unknown;
|
|
@@ -79,10 +99,14 @@ export type FastifyValidationResult = {
|
|
|
79
99
|
};
|
|
80
100
|
/**
|
|
81
101
|
* @brief fastify validator.
|
|
102
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
103
|
+
* adding framework dependencies.
|
|
82
104
|
*/
|
|
83
105
|
export type FastifyValidator = (value: unknown) => FastifyValidationResult;
|
|
84
106
|
/**
|
|
85
107
|
* @brief fastify validator compiler.
|
|
108
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
109
|
+
* adding framework dependencies.
|
|
86
110
|
*/
|
|
87
111
|
export type FastifyValidatorCompiler = (route: FastifyValidatorRoute) => FastifyValidator;
|
|
88
112
|
/**
|
|
@@ -99,6 +123,8 @@ export type FastifyValidatorCompilerSourceMap = Readonly<Partial<Record<FastifyH
|
|
|
99
123
|
export type FastifyValidatorCompilerSource = SyncAdapterSource | FastifyValidatorCompilerSourceMap;
|
|
100
124
|
/**
|
|
101
125
|
* @brief react hook form field error.
|
|
126
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
127
|
+
* adding framework dependencies.
|
|
102
128
|
*/
|
|
103
129
|
export interface ReactHookFormFieldError {
|
|
104
130
|
readonly type: string;
|
|
@@ -114,6 +140,8 @@ export interface ReactHookFormErrors {
|
|
|
114
140
|
}
|
|
115
141
|
/**
|
|
116
142
|
* @brief react hook form resolver result.
|
|
143
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
144
|
+
* adding framework dependencies.
|
|
117
145
|
*/
|
|
118
146
|
export interface ReactHookFormResolverResult<TValue> {
|
|
119
147
|
readonly values: TValue | Readonly<Record<string, never>>;
|
|
@@ -121,32 +149,46 @@ export interface ReactHookFormResolverResult<TValue> {
|
|
|
121
149
|
}
|
|
122
150
|
/**
|
|
123
151
|
* @brief react hook form resolver.
|
|
152
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
153
|
+
* adding framework dependencies.
|
|
124
154
|
*/
|
|
125
155
|
export type ReactHookFormResolver<TValue> = (values: unknown, context: unknown, options: unknown) => Promise<ReactHookFormResolverResult<TValue>>;
|
|
126
156
|
/**
|
|
127
157
|
* @brief react hook form resolver options.
|
|
158
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
159
|
+
* adding framework dependencies.
|
|
128
160
|
*/
|
|
129
161
|
export interface ReactHookFormResolverOptions {
|
|
130
162
|
readonly messages: Partial<IssueMessageOptions> | undefined;
|
|
131
163
|
}
|
|
132
164
|
/**
|
|
133
165
|
* @brief to trpc parser.
|
|
166
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
167
|
+
* adding framework dependencies.
|
|
134
168
|
*/
|
|
135
169
|
export declare function toTrpcParser<TSource extends SyncAdapterSource>(source: TSource): TrpcParser<InferSyncAdapter<TSource>>;
|
|
136
170
|
/**
|
|
137
171
|
* @brief to async trpc parser.
|
|
172
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
173
|
+
* adding framework dependencies.
|
|
138
174
|
*/
|
|
139
175
|
export declare function toAsyncTrpcParser<TSource extends AsyncDecodeSource>(source: TSource): AsyncTrpcParser<InferAdapter<TSource>>;
|
|
140
176
|
/**
|
|
141
177
|
* @brief to fastify route schema.
|
|
178
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
179
|
+
* adding framework dependencies.
|
|
142
180
|
*/
|
|
143
181
|
export declare function toFastifyRouteSchema(guard: Guard<unknown, Presence>, options?: Partial<FastifyRouteSchemaOptions>): Result<FastifyRouteSchema, readonly JsonSchemaExportIssue[]>;
|
|
144
182
|
/**
|
|
145
183
|
* @brief to fastify validator compiler.
|
|
184
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
185
|
+
* adding framework dependencies.
|
|
146
186
|
*/
|
|
147
187
|
export declare function toFastifyValidatorCompiler(source: FastifyValidatorCompilerSource): FastifyValidatorCompiler;
|
|
148
188
|
/**
|
|
149
189
|
* @brief to react hook form resolver.
|
|
190
|
+
* @details Adapter shapes stay local so TypeSea diagnostics can be translated without
|
|
191
|
+
* adding framework dependencies.
|
|
150
192
|
*/
|
|
151
193
|
export declare function toReactHookFormResolver<TSource extends AsyncDecodeSource>(source: TSource, options?: Partial<ReactHookFormResolverOptions>): ReactHookFormResolver<InferAdapter<TSource>>;
|
|
152
194
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,YAAY,EAEpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,qBAAqB,EACrB,KAAK,KAAK,EACV,KAAK,QAAQ,EAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAEH,KAAK,mBAAmB,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAEH,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC7B,MAAM,yBAAyB,CAAC;AAGjC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,MAAM;IAC9B,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;CAC9C;AAED;;;;GAIG;AACH,MAAM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