zod-compiler 1.20.0 → 1.22.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 +90 -58
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +8 -1
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/emitter.d.ts.map +1 -1
- package/dist/cli/emitter.js +8 -1
- package/dist/cli/emitter.js.map +1 -1
- package/dist/core/codegen/context.d.ts +6 -3
- package/dist/core/codegen/context.d.ts.map +1 -1
- package/dist/core/codegen/context.js +25 -9
- package/dist/core/codegen/context.js.map +1 -1
- package/dist/core/codegen/issue-decls.d.ts +45 -0
- package/dist/core/codegen/issue-decls.d.ts.map +1 -1
- package/dist/core/codegen/issue-decls.js +53 -0
- package/dist/core/codegen/issue-decls.js.map +1 -1
- package/dist/core/codegen/schemas/array.d.ts.map +1 -1
- package/dist/core/codegen/schemas/array.js +9 -3
- package/dist/core/codegen/schemas/array.js.map +1 -1
- package/dist/core/codegen/schemas/effect.d.ts +20 -2
- package/dist/core/codegen/schemas/effect.d.ts.map +1 -1
- package/dist/core/codegen/schemas/effect.js +47 -3
- package/dist/core/codegen/schemas/effect.js.map +1 -1
- package/dist/core/codegen/schemas/number.d.ts.map +1 -1
- package/dist/core/codegen/schemas/number.js +9 -3
- package/dist/core/codegen/schemas/number.js.map +1 -1
- package/dist/core/codegen/schemas/object.d.ts.map +1 -1
- package/dist/core/codegen/schemas/object.js +65 -6
- package/dist/core/codegen/schemas/object.js.map +1 -1
- package/dist/core/codegen/schemas/string.d.ts.map +1 -1
- package/dist/core/codegen/schemas/string.js +9 -3
- package/dist/core/codegen/schemas/string.js.map +1 -1
- package/dist/core/extract/checks.d.ts +14 -1
- package/dist/core/extract/checks.d.ts.map +1 -1
- package/dist/core/extract/checks.js +39 -2
- package/dist/core/extract/checks.js.map +1 -1
- package/dist/core/extract/effects.d.ts +23 -0
- package/dist/core/extract/effects.d.ts.map +1 -1
- package/dist/core/extract/effects.js +19 -0
- package/dist/core/extract/effects.js.map +1 -1
- package/dist/core/extract/extractors/array.d.ts.map +1 -1
- package/dist/core/extract/extractors/array.js +9 -3
- package/dist/core/extract/extractors/array.js.map +1 -1
- package/dist/core/extract/extractors/number.d.ts.map +1 -1
- package/dist/core/extract/extractors/number.js +3 -2
- package/dist/core/extract/extractors/number.js.map +1 -1
- package/dist/core/extract/extractors/object.d.ts.map +1 -1
- package/dist/core/extract/extractors/object.js +14 -11
- package/dist/core/extract/extractors/object.js.map +1 -1
- package/dist/core/extract/extractors/pipe.d.ts.map +1 -1
- package/dist/core/extract/extractors/pipe.js +15 -1
- package/dist/core/extract/extractors/pipe.js.map +1 -1
- package/dist/core/extract/extractors/string.d.ts.map +1 -1
- package/dist/core/extract/extractors/string.js +3 -2
- package/dist/core/extract/extractors/string.js.map +1 -1
- package/dist/core/extract/types.d.ts +6 -0
- package/dist/core/extract/types.d.ts.map +1 -1
- package/dist/core/iife.d.ts +8 -2
- package/dist/core/iife.d.ts.map +1 -1
- package/dist/core/iife.js +8 -2
- package/dist/core/iife.js.map +1 -1
- package/dist/core/types.d.ts +37 -4
- package/dist/core/types.d.ts.map +1 -1
- package/dist/unplugin/virtual.d.ts.map +1 -1
- package/dist/unplugin/virtual.js +3 -1
- package/dist/unplugin/virtual.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -706,17 +706,15 @@ All standard Zod checks are supported: `min`, `max`, `length`, `email`, `url`, `
|
|
|
706
706
|
|
|
707
707
|
### Falls Back to Zod (Still Works, Not Faster)
|
|
708
708
|
|
|
709
|
-
These
|
|
710
|
-
|
|
711
|
-
| Type
|
|
712
|
-
|
|
|
713
|
-
| `transform`
|
|
714
|
-
| `
|
|
715
|
-
| `
|
|
716
|
-
| `
|
|
717
|
-
| `
|
|
718
|
-
| `lazy` (unresolvable inner) | Getter throws / inner type can't be resolved at compile time | Ensure the lazy getter returns a static schema |
|
|
719
|
-
| `.catchall(schema)` | Unknown keys validated against a value schema | `strictObject` and `looseObject` both compile |
|
|
709
|
+
These reach JavaScript that generated code cannot reproduce — an opaque callback, or control flow that depends on one:
|
|
710
|
+
|
|
711
|
+
| Type | Why | Alternative |
|
|
712
|
+
| ---------------------------------------- | ------------------------------------------------------------ | ---------------------------------------------- |
|
|
713
|
+
| `transform` that is async or takes `ctx` | A promise result, or zod's issue-collection protocol | Use a plain single-argument callback |
|
|
714
|
+
| `superRefine` followed by another check | An aborting issue truncates zod's remaining checks | Put the `superRefine` last in the chain |
|
|
715
|
+
| `custom` / raw `.check(fn)` | Arbitrary validation logic against zod's raw payload | Use `superRefine`, which compiles |
|
|
716
|
+
| `preprocess` | Input preprocessing function | Use `z.coerce` when possible |
|
|
717
|
+
| `lazy` (unresolvable inner) | Getter throws / inner type can't be resolved at compile time | Ensure the lazy getter returns a static schema |
|
|
720
718
|
|
|
721
719
|
**Zero-capture effects compile:** a `transform`/`refine` callback that takes a
|
|
722
720
|
single argument and references only its own parameters, locals, and safe
|
|
@@ -725,22 +723,55 @@ inlined into the generated validator. `z.string().transform((s) => s.trim())`
|
|
|
725
723
|
compiles; `z.string().transform((s) => s + suffix)` falls back (it captures
|
|
726
724
|
`suffix`).
|
|
727
725
|
|
|
728
|
-
**Every `refine` compiles, captures or not.** A
|
|
729
|
-
inlined is instead **called by reference** — the generated validator
|
|
730
|
-
your own function object, reached from the schema — so the schema keeps
|
|
731
|
-
compiled path either way. This matters most
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
726
|
+
**Every `refine` and `transform` compiles, captures or not.** A callback that
|
|
727
|
+
cannot be inlined is instead **called by reference** — the generated validator
|
|
728
|
+
invokes your own function object, reached from the schema — so the schema keeps
|
|
729
|
+
its compiled path either way. This matters most on the root, where one captured
|
|
730
|
+
callback used to send the whole object through Zod:
|
|
731
|
+
|
|
732
|
+
- `z.object({ … }).refine((d) => d.password === d.confirm)` — the cross-field
|
|
733
|
+
check. Measured on a six-field object: **246.7 ns → 8.5 ns (29x)**, against
|
|
734
|
+
Zod's own 250.5 ns.
|
|
735
|
+
- `z.object({ … }).transform((d) => ({ ...d, id: prefix + d.id }))` —
|
|
736
|
+
**163.7 ns → 12.7 ns**. That case was previously _slower than not compiling
|
|
737
|
+
at all_ (Zod itself: 136.7 ns), because the delegate wrapper sat on top of
|
|
738
|
+
Zod's parse.
|
|
739
|
+
|
|
740
|
+
Where the callback itself dominates, compiled output reaches its cost and no
|
|
741
|
+
more: a captured `refine` doing `allowedDomains.some(…)` measures 23.9 ns
|
|
742
|
+
against 24.1 ns for calling that predicate alone — zero remaining validation
|
|
743
|
+
overhead.
|
|
744
|
+
|
|
745
|
+
**`superRefine` compiles too.** It has no verdict to read — the callback takes
|
|
746
|
+
Zod's payload and pushes issues onto it — so it is called through a reference to
|
|
747
|
+
Zod's own wrapper with a synthesized payload, which leaves issue construction
|
|
748
|
+
Zod's job and keeps error shapes identical by construction. That turns the most
|
|
749
|
+
common form of cross-field validation from a total fallback into the 2.3M →
|
|
750
|
+
13.3M row below; measured in isolation, where the harness floor stops
|
|
751
|
+
compressing the ratio, the same object runs 357.8 ns → 39.9 ns (9.0x) and an
|
|
752
|
+
array of numbers 240.7 ns → 5.3 ns (46x), with rejecting inputs 31-92x. Two
|
|
753
|
+
shapes still delegate: a `superRefine` with another check after it
|
|
754
|
+
(an issue marked `fatal` aborts Zod's remaining chain, which generated code —
|
|
755
|
+
running every check — cannot reproduce), and a raw `.check(fn)`, where the
|
|
756
|
+
callback holds the payload unmediated rather than through Zod's wrapper. An
|
|
757
|
+
`async` callback is invisible at compile time, since the reference points at the
|
|
758
|
+
wrapper; the promise it returns raises Zod's own `$ZodAsyncError`, exactly as a
|
|
759
|
+
synchronous Zod parse does. `ctx.value`, `ctx.aborted`, and direct
|
|
760
|
+
`ctx.issues.push` are all honored.
|
|
761
|
+
|
|
762
|
+
**`.catchall(schema)` compiles.** Unknown keys are validated against the value
|
|
763
|
+
schema by the same bare `for-in` the `strict` pass uses — zod's own
|
|
764
|
+
`handleCatchall` iteration, inherited enumerable keys included — with each issue
|
|
765
|
+
reported at its key. A header bag (`z.object({...}).catchall(z.string())`)
|
|
766
|
+
measures 117.2 ns → 9.0 ns (**13x**), a numeric metrics bag 105.1 ns → 11.5 ns
|
|
767
|
+
(9.1x); both were 1.0x. Value-rewriting catchalls (`z.coerce.number()`,
|
|
768
|
+
`.trim()`, a `.default()`) write through a clone, so the caller's input is never
|
|
769
|
+
mutated. A catchall that itself delegates keeps the whole object delegated —
|
|
770
|
+
one zod call beats one per unknown key.
|
|
740
771
|
|
|
741
772
|
**Partial fallback:** If an object has 10 properties and 1 uses `transform`, the other 9 are still compiled. Only the `transform` property falls back to Zod.
|
|
742
773
|
|
|
743
|
-
**Recursive schemas compile** — whether directly self-recursive (`z.lazy(() => Self)`), mutually recursive (`A` ↔ `B`), or **nested as a field of a larger root** (a recursive `Comment` inside `z.object({ thread, root: Comment })`). Each distinct recursive shape is hosted once as a dedicated validator and reached by reference, so the whole structure stays on the fast path instead of delegating to Zod — a recursive type nested in an API envelope runs **12–
|
|
774
|
+
**Recursive schemas compile** — whether directly self-recursive (`z.lazy(() => Self)`), mutually recursive (`A` ↔ `B`), or **nested as a field of a larger root** (a recursive `Comment` inside `z.object({ thread, root: Comment })`). Each distinct recursive shape is hosted once as a dedicated validator and reached by reference, so the whole structure stays on the fast path instead of delegating to Zod — a recursive type nested in an API envelope runs **12–32x faster than Zod** (see the benchmark table). A `lazy` schema only falls back when its getter can't be resolved at compile time.
|
|
744
775
|
|
|
745
776
|
**Tip:** Run `npx zod-compiler check` to see exactly which parts of your schemas are compiled and which fall back.
|
|
746
777
|
|
|
@@ -781,43 +812,44 @@ Matching Zod on these would mean allocating a fresh object (or a `Reflect.ownKey
|
|
|
781
812
|
|
|
782
813
|
5-way comparison: **Zod v3** vs **Zod v4** vs **zod-compiler** vs **[Typia](https://typia.io/)** vs **[AJV](https://ajv.js.org/)**
|
|
783
814
|
|
|
784
|
-
| Scenario
|
|
785
|
-
|
|
|
786
|
-
| simple string
|
|
787
|
-
| string (min/max)
|
|
788
|
-
| number (int+positive)
|
|
789
|
-
| enum
|
|
790
|
-
| bigint (min/max)
|
|
791
|
-
| tuple [string, int, bool]
|
|
792
|
-
| record\<string, number\>
|
|
793
|
-
| set\<string\> (5 items)
|
|
794
|
-
| set\<string\> (20 items)
|
|
795
|
-
| map\<string, number\> (5 entries)
|
|
796
|
-
| map\<string, number\> (20 entries)
|
|
797
|
-
| pipe (non-transform)
|
|
798
|
-
| discriminatedUnion (3 variants)
|
|
799
|
-
| discriminatedUnion (8 variants, rotating)
|
|
800
|
-
| plain union of 8 tagged objects (auto-discrim.)
|
|
801
|
-
| strict object (DB row)
|
|
802
|
-
| medium object (valid)
|
|
803
|
-
| medium object (invalid)
|
|
804
|
-
| large object (10 items)
|
|
805
|
-
| large object (100 items)
|
|
806
|
-
| recursive tree (7 nodes)
|
|
807
|
-
| recursive tree (121 nodes)
|
|
808
|
-
| nested recursion (7 nodes)
|
|
809
|
-
| nested recursion (121 nodes)
|
|
810
|
-
| deeply nested object (243 leaves)
|
|
811
|
-
| event log (combined)
|
|
812
|
-
| object with transform (zero-capture)
|
|
813
|
-
| array 10 × transform (zero-capture)
|
|
814
|
-
| array 50 × transform (zero-capture)
|
|
815
|
-
| object with captured transform
|
|
816
|
-
| object with captured refine (cross-field)
|
|
815
|
+
| Scenario | Zod v3 | Zod v4 | **zod-compiler** | Typia | AJV | vs Zod v4 |
|
|
816
|
+
| ----------------------------------------------- | ------ | ------ | ---------------- | ----- | ----- | --------- |
|
|
817
|
+
| simple string | 13.3M | 14.5M | **17.3M** | 17.7M | 17.9M | 1.2x |
|
|
818
|
+
| string (min/max) | 12.4M | 8.0M | **17.0M** | 17.9M | 15.7M | 2.1x |
|
|
819
|
+
| number (int+positive) | 12.6M | 8.3M | **17.4M** | 18.0M | 18.1M | 2.1x |
|
|
820
|
+
| enum | 12.3M | 12.6M | **17.6M** | 17.8M | 18.3M | 1.4x |
|
|
821
|
+
| bigint (min/max) | 12.2M | 7.8M | **17.0M** | — | — | 2.2x |
|
|
822
|
+
| tuple [string, int, bool] | 5.9M | 6.5M | **16.5M** | 16.5M | 16.4M | 2.6x |
|
|
823
|
+
| record\<string, number\> | 3.2M | 2.8M | **15.2M** | 11.9M | 15.7M | 5.5x |
|
|
824
|
+
| set\<string\> (5 items) | 3.7M | 2.3M | **15.0M** | — | — | 6.5x |
|
|
825
|
+
| set\<string\> (20 items) | 1.3M | 715K | **11.8M** | — | — | **16x** |
|
|
826
|
+
| map\<string, number\> (5 entries) | 2.0M | 1.4M | **13.2M** | — | — | 9.6x |
|
|
827
|
+
| map\<string, number\> (20 entries) | 665K | 360K | **8.4M** | — | — | **23x** |
|
|
828
|
+
| pipe (non-transform) | 8.7M | 5.7M | **16.7M** | — | — | 2.9x |
|
|
829
|
+
| discriminatedUnion (3 variants) | 3.5M | 4.2M | **16.0M** | 15.9M | 7.9M | 3.9x |
|
|
830
|
+
| discriminatedUnion (8 variants, rotating) | 2.7M | 3.5M | **10.1M** | — | — | 2.9x |
|
|
831
|
+
| plain union of 8 tagged objects (auto-discrim.) | 374K | 678K | **10.0M** | — | — | **15x** |
|
|
832
|
+
| strict object (DB row) | 1.8M | 3.2M | **8.1M** | — | — | 2.5x |
|
|
833
|
+
| medium object (valid) | 1.9M | 2.4M | **9.9M** | 11.5M | 7.6M | 4.1x |
|
|
834
|
+
| medium object (invalid) | 553K | 80K | **15.1M** | 3.0M | 7.8M | **188x** |
|
|
835
|
+
| large object (10 items) | 122K | 166K | **7.9M** | 6.1M | 1.2M | **48x** |
|
|
836
|
+
| large object (100 items) | 14K | 18K | **1.4M** | 1.3M | 127K | **77x** |
|
|
837
|
+
| recursive tree (7 nodes) | 589K | 2.1M | **12.8M** | 12.0M | 4.9M | 6.0x |
|
|
838
|
+
| recursive tree (121 nodes) | 32K | 143K | **2.5M** | 2.0M | 392K | **18x** |
|
|
839
|
+
| nested recursion (7 nodes) | 394K | 1.0M | **12.1M** | 11.1M | 3.0M | **12x** |
|
|
840
|
+
| nested recursion (121 nodes) | 25K | 66K | **2.1M** | 1.7M | 219K | **32x** |
|
|
841
|
+
| deeply nested object (243 leaves) | 11K | 20K | **1.2M** | 1.1M | 129K | **59x** |
|
|
842
|
+
| event log (combined) | 389K | 645K | **6.4M** | — | — | 9.9x |
|
|
843
|
+
| object with transform (zero-capture) | 1.2M | 2.0M | **6.3M** | — | — | 3.1x |
|
|
844
|
+
| array 10 × transform (zero-capture) | 126K | 208K | **3.3M** | — | — | **16x** |
|
|
845
|
+
| array 50 × transform (zero-capture) | 26K | 45K | **839K** | — | — | **19x** |
|
|
846
|
+
| object with captured transform | 1.3M | 6.4M | **15.0M** | — | — | 2.4x |
|
|
847
|
+
| object with captured refine (cross-field) | 1.6M | 2.5M | **16.1M** | — | — | 6.4x |
|
|
848
|
+
| object with superRefine (cross-field) | 1.6M | 2.3M | **13.3M** | — | — | 5.7x |
|
|
817
849
|
|
|
818
850
|
_ops/s, higher is better. "—" = not supported by the library. Measured with `vitest bench` on Apple M4 Max (zod 4.3.6, zod v3 3.23.8, typia 12, ajv 8), best of two full runs; rows reproduce within ~5% between runs. The harness itself costs ~55 ns per iteration — the fastest rows sit at that floor — so it compresses the top of the range: gaps between the three AOT columns on the primitive rows are below the noise, not real._
|
|
819
851
|
|
|
820
|
-
Performance scales with schema complexity. Nested objects and arrays see the biggest gains because zod-compiler eliminates per-node traversal overhead. Deeply nested schemas (the 243-leaf dashboard row) stay fast because oversized fast-check functions are split into smaller boolean helpers, each kept within V8's optimizing-compiler budget. `discriminatedUnion` dispatches instead of trying options in sequence the way Zod does, and each case validates only its variant's distinctive fields — the object type-guard and the discriminator are checked once before dispatch, never re-checked inside the matched case (a redundancy the engine only elides on unions small enough to inline, so large unions get a measured ~1.5x on the fast check). Dispatch is genuinely O(1) for string discriminators: a `switch` over string labels is only _written_ as a jump, V8 lowers it to sequential `===` comparisons (~0.5 ns per preceding case, so 52 ns of pure dispatch at 80 variants), so the discriminator goes through a `{value: ordinal}` table into a dense integer switch — measured 1.9x at 8 variants and 2.8x at 60, for ~1% more generated bytes. Unions of two variants, or with non-string discriminators, keep the plain switch. A **plain `z.union`** of objects that all pin a shared key to disjoint literals is auto-detected and lowered to the same switch dispatch — so an untagged union written without `discriminatedUnion` still validates in O(1) (15x faster than Zod here), as long as it has enough options to outweigh the switch's setup cost; below that it keeps the fully-inlined `||`-chain, whose options and per-option checks are ordered cheapest-first so a non-matching option is dropped without running its regexes. The invalid-input row is large because failed `safeParse` defers error materialization until `.error` is read.
|
|
852
|
+
Performance scales with schema complexity. Nested objects and arrays see the biggest gains because zod-compiler eliminates per-node traversal overhead. Deeply nested schemas (the 243-leaf dashboard row) stay fast because oversized fast-check functions are split into smaller boolean helpers, each kept within V8's optimizing-compiler budget. `discriminatedUnion` dispatches instead of trying options in sequence the way Zod does, and each case validates only its variant's distinctive fields — the object type-guard and the discriminator are checked once before dispatch, never re-checked inside the matched case (a redundancy the engine only elides on unions small enough to inline, so large unions get a measured ~1.5x on the fast check). Dispatch is genuinely O(1) for string discriminators: a `switch` over string labels is only _written_ as a jump, V8 lowers it to sequential `===` comparisons (~0.5 ns per preceding case, so 52 ns of pure dispatch at 80 variants), so the discriminator goes through a `{value: ordinal}` table into a dense integer switch — measured 1.9x at 8 variants and 2.8x at 60, for ~1% more generated bytes. Unions of two variants, or with non-string discriminators, keep the plain switch. A **plain `z.union`** of objects that all pin a shared key to disjoint literals is auto-detected and lowered to the same switch dispatch — so an untagged union written without `discriminatedUnion` still validates in O(1) (15x faster than Zod here), as long as it has enough options to outweigh the switch's setup cost; below that it keeps the fully-inlined `||`-chain, whose options and per-option checks are ordered cheapest-first so a non-matching option is dropped without running its regexes. The invalid-input row is large because failed `safeParse` defers error materialization until `.error` is read. `transform`/`refine` callbacks compile whether or not they capture (3-19x): a zero-capture one is inlined from its source, a capturing one is called by reference rather than costing the schema its compiled path — the cross-field refine row measures 2.5M → 16.1M, and captured transforms went from matching Zod (1.0x) to 2.4x. `superRefine` compiles as well, called through a reference to Zod's own payload wrapper (2.3M → 13.3M here, from a total fallback); only a `superRefine` with another check after it, raw `.check(fn)`, and `ctx`-taking or async transforms still delegate.
|
|
821
853
|
|
|
822
854
|
`parse()` (throwing API) rides a zero-allocation fast path: medium object 2.4M → 10.2M ops/s (4.3x), large object (100 items) 18K → 1.4M ops/s (78x).
|
|
823
855
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[],"mappings":"AAkFA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA4HnE"}
|
|
@@ -92,7 +92,14 @@ export async function runCheck(options) {
|
|
|
92
92
|
for (const s of schemas) {
|
|
93
93
|
let ir;
|
|
94
94
|
try {
|
|
95
|
-
|
|
95
|
+
// Collect refs exactly as the compile pipeline does. A callback that
|
|
96
|
+
// captures is compiled by REFERENCE through an `__rf[]` entry, which
|
|
97
|
+
// only happens when a ref table is present — extracting without one
|
|
98
|
+
// reports every captured refine/transform and every superRefine as a
|
|
99
|
+
// fallback, so `check` claimed 0% on schemas `generate` compiles in
|
|
100
|
+
// full and told the user to rewrite code that was already fast.
|
|
101
|
+
const refEntries = [];
|
|
102
|
+
ir = extractSchema(s.schema, refEntries);
|
|
96
103
|
}
|
|
97
104
|
catch (e) {
|
|
98
105
|
err(`${c.red}error${c.reset} Failed to extract "${s.exportName}" in ${relPath}: ${getErrorMessage(e)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/cli/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEpD,+EAA+E;AAE/E,SAAS,UAAU,CAAC,IAAoB,EAAE,CAAS,EAAE,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,IAAI;IAC7E,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,SAAS,GAAG,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9D,MAAM,WAAW,GAAG,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK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AS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,kBAAkB,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/cli/emitter.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,kBAAkB,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAuDR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAc3F;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1F"}
|
package/dist/cli/emitter.js
CHANGED
|
@@ -16,7 +16,14 @@ export function generateCompiledFileContent(schemas, sourceRelPath, options) {
|
|
|
16
16
|
const schemasNeedingImport = schemas.filter((s) => zodCompat || s.refEntries.length > 0);
|
|
17
17
|
const exports = schemas.map((schema) => {
|
|
18
18
|
const needsImport = zodCompat || schema.refEntries.length > 0;
|
|
19
|
-
|
|
19
|
+
// `compile()` returns the schema augmented with a non-enumerable `schema`
|
|
20
|
+
// self-reference; auto-discovery (the default) instead finds plain exported
|
|
21
|
+
// Zod schemas, which have no such property. Both shapes must resolve, so
|
|
22
|
+
// fall through to the export itself — reading `.schema` alone yields
|
|
23
|
+
// undefined there, which silently cost __zcMkv the real schema to augment
|
|
24
|
+
// and hard-crashed every `__rf[]` base at module load.
|
|
25
|
+
const src = `__src_${schema.exportName}`;
|
|
26
|
+
const schemaExpr = needsImport ? `((${src} as any).schema ?? ${src})` : "";
|
|
20
27
|
return `export const ${schema.exportName} = ${generateIIFE(schemaExpr, schema, { zodCompat })};`;
|
|
21
28
|
});
|
|
22
29
|
const importLine = schemasNeedingImport.length > 0
|
package/dist/cli/emitter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/cli/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAoBzB,MAAM,UAAU,2BAA2B,CACzC,OAA6B,EAC7B,aAAqB,EACrB,OAAwB;IAExB,IAAI,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IAC9D,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,UAAU,GAAG,KAAK,UAAU,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,KAAK,KAAK,CAAC;IAE/C,yEAAyE;IACzE,2DAA2D;IAC3D,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAElF,y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,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BigIntCheckIR, CheckIR, DateCheckIR,
|
|
1
|
+
import type { BigIntCheckIR, CheckIR, DateCheckIR, SchemaIR, SetCheckIR } from "../types.js";
|
|
2
2
|
import type { SharedSchemaPlan } from "./dedupe.js";
|
|
3
3
|
/** Codegen output mode. "inline" emits self-contained code (CLI .compiled.ts). "lean" emits references to imports from "virtual:zod-compiler/runtime" (unplugin). */
|
|
4
4
|
export type CodegenMode = "inline" | "lean";
|
|
@@ -221,7 +221,7 @@ export declare function emitTemp(ctx: CodeGenContext, prefix: string): string;
|
|
|
221
221
|
*/
|
|
222
222
|
export declare function emitEffectFn(ctx: CodeGenContext, source: string): string;
|
|
223
223
|
/**
|
|
224
|
-
* Callable expression for a refine predicate.
|
|
224
|
+
* Callable expression for a user callback — a refine predicate or a transform.
|
|
225
225
|
*
|
|
226
226
|
* A zero-capture callback is hosted from its source text; one that CAPTURES
|
|
227
227
|
* outer variables is called by reference through `__rf[N]` — the user's own
|
|
@@ -230,7 +230,10 @@ export declare function emitEffectFn(ctx: CodeGenContext, source: string): strin
|
|
|
230
230
|
* re-read per call, for the same reason call-invoked helpers are (a per-call
|
|
231
231
|
* array element load is not a foldable callee).
|
|
232
232
|
*/
|
|
233
|
-
export declare function
|
|
233
|
+
export declare function emitEffectCallable(ctx: CodeGenContext, effect: {
|
|
234
|
+
refIndex?: number | undefined;
|
|
235
|
+
source?: string | undefined;
|
|
236
|
+
}): string;
|
|
234
237
|
/**
|
|
235
238
|
* Pristine fallback delegate: declare `var __rfp_N=__rf[N].safeParse.bind(__rf[N]);`
|
|
236
239
|
* in the preamble and return the variable name. Generated code must NEVER read
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/codegen/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/codegen/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAOpD,qKAAqK;AACrK,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;;OAQG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,uFAAuF;AACvF,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED,6FAA6F;AAC7F,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,2BAA2B;IAC3B,IAA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3B,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,EACrD,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,GACpD,MAAM,CAER"}
|
|
@@ -27,7 +27,7 @@ export function emitEffectFn(ctx, source) {
|
|
|
27
27
|
return name;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Callable expression for a refine predicate.
|
|
30
|
+
* Callable expression for a user callback — a refine predicate or a transform.
|
|
31
31
|
*
|
|
32
32
|
* A zero-capture callback is hosted from its source text; one that CAPTURES
|
|
33
33
|
* outer variables is called by reference through `__rf[N]` — the user's own
|
|
@@ -36,13 +36,13 @@ export function emitEffectFn(ctx, source) {
|
|
|
36
36
|
* re-read per call, for the same reason call-invoked helpers are (a per-call
|
|
37
37
|
* array element load is not a foldable callee).
|
|
38
38
|
*/
|
|
39
|
-
export function
|
|
40
|
-
if (
|
|
41
|
-
return emitConstant(ctx, "rfn", `__rf[${
|
|
42
|
-
if (
|
|
43
|
-
throw new Error("
|
|
39
|
+
export function emitEffectCallable(ctx, effect) {
|
|
40
|
+
if (effect.refIndex !== undefined)
|
|
41
|
+
return emitConstant(ctx, "rfn", `__rf[${effect.refIndex}]`);
|
|
42
|
+
if (effect.source === undefined) {
|
|
43
|
+
throw new Error("effect has neither inlineable source nor a reference index");
|
|
44
44
|
}
|
|
45
|
-
return emitEffectFn(ctx,
|
|
45
|
+
return emitEffectFn(ctx, effect.source);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Pristine fallback delegate: declare `var __rfp_N=__rf[N].safeParse.bind(__rf[N]);`
|
|
@@ -300,6 +300,17 @@ export function extendStaticPath(parentPath, key) {
|
|
|
300
300
|
export function extendStaticPathIndex(parentPath, index) {
|
|
301
301
|
return extendPath(parentPath, String(index));
|
|
302
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* A superRefine callback receives zod's payload, whose `value` is public,
|
|
305
|
+
* typed, writable API ($RefinementCtx extends ParsePayload) — so any node
|
|
306
|
+
* carrying one MAY rewrite its value and must be treated as mutating. Which
|
|
307
|
+
* callbacks actually do is undecidable here; the emitted fast check settles it
|
|
308
|
+
* at runtime by refusing when the value changed (see ZC_SR_OK_DECL), so a
|
|
309
|
+
* non-mutating callback still exits through the fast path.
|
|
310
|
+
*/
|
|
311
|
+
function hasSuperRefine(checks) {
|
|
312
|
+
return checks !== undefined && checks.some((c) => c.kind === "super_refine_effect");
|
|
313
|
+
}
|
|
303
314
|
/**
|
|
304
315
|
* Check if a SchemaIR tree produces output that is not the input itself —
|
|
305
316
|
* either value-mutating operations (coerce, default, catch, overwrite) that
|
|
@@ -315,8 +326,10 @@ export function hasMutation(ir) {
|
|
|
315
326
|
// url checks trim (and optionally normalize) the value; overwrite
|
|
316
327
|
// effects (.trim(), .toLowerCase()) rewrite it.
|
|
317
328
|
return (ir.coerce === true ||
|
|
329
|
+
hasSuperRefine(ir.checks) ||
|
|
318
330
|
ir.checks.some((c) => c.kind === "overwrite_effect" || (c.kind === "string_format" && c.format === "url")));
|
|
319
331
|
case "number":
|
|
332
|
+
return ir.coerce === true || hasSuperRefine(ir.checks);
|
|
320
333
|
case "boolean":
|
|
321
334
|
case "bigint":
|
|
322
335
|
case "date":
|
|
@@ -333,9 +346,12 @@ export function hasMutation(ir) {
|
|
|
333
346
|
// by-reference fast path, and intersections of strip objects delegate to
|
|
334
347
|
// zod (see extractIntersection's hasMutation guard) — matching zod's
|
|
335
348
|
// parse-both-sides-then-merge semantics instead of over-stripping.
|
|
336
|
-
return ir.stripUnknownKeys === true ||
|
|
349
|
+
return (ir.stripUnknownKeys === true ||
|
|
350
|
+
hasSuperRefine(ir.checks) ||
|
|
351
|
+
(ir.catchall !== undefined && hasMutation(ir.catchall)) ||
|
|
352
|
+
Object.values(ir.properties).some((p) => hasMutation(p)));
|
|
337
353
|
case "array":
|
|
338
|
-
return hasMutation(ir.element);
|
|
354
|
+
return hasSuperRefine(ir.checks) || hasMutation(ir.element);
|
|
339
355
|
case "tuple":
|
|
340
356
|
return ir.items.some(hasMutation) || (ir.rest !== null && hasMutation(ir.rest));
|
|
341
357
|
case "record":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/codegen/context.ts"],"names":[],"mappings":"AASA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AA0O/B,gFAAgF;AAEhF,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,GAAmB,EAAE,MAAc;IAC1D,OAAO,KAAK,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,GAAmB,EAAE,MAAc;IAC9D,GAAG,CAAC,aAAa,KAAK,IAAI,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,MAAM,IAAI,GAAG,QAAQ,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;IACrC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC;IAC9C,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAmB,EAAE,KAA0B;IACjF,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC7F,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,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function __zcFsr(v,s){var vd=((\"\"+v).split
|
|
|
34
34
|
* per call would not.
|
|
35
35
|
*/
|
|
36
36
|
export declare const ZC_HOP_DECL = "const __zcHop=Object.prototype.hasOwnProperty;";
|
|
37
|
+
/**
|
|
38
|
+
* superRefine fast-check: run the payload callback on a throwaway payload and
|
|
39
|
+
* report whether it both added nothing AND left the value alone. zod's own
|
|
40
|
+
* wrapper (the referenced function) installs `addIssue` and normalizes what the
|
|
41
|
+
* user adds, so the verdict is zod's; the issues themselves are re-collected by
|
|
42
|
+
* the slow walk.
|
|
43
|
+
*
|
|
44
|
+
* The `p.value===v` half is what lets a superRefine node keep a fast path at
|
|
45
|
+
* all. `value` is writable public API ($RefinementCtx extends ParsePayload), so
|
|
46
|
+
* a callback may rewrite it, and the fast path's caller returns the ORIGINAL
|
|
47
|
+
* input on success — which would then be stale. Reporting false when the value
|
|
48
|
+
* moved routes those parses into the slow walk, which propagates the new value
|
|
49
|
+
* (see ZC_SR_DECL). Callbacks that only validate — effectively all of them —
|
|
50
|
+
* still take the fast exit.
|
|
51
|
+
*/
|
|
52
|
+
export declare const ZC_SR_OK_DECL: string;
|
|
53
|
+
/**
|
|
54
|
+
* Module-local (never imported by generated code) — __zcSr/__zcSrOk call it.
|
|
55
|
+
* Lean mode declares it in the runtime module beside them; inline mode pushes it
|
|
56
|
+
* into the preamble alongside whichever of the two is used.
|
|
57
|
+
*
|
|
58
|
+
* Invoke the referenced wrapper, reproducing zod's synchronous-parse contract:
|
|
59
|
+
* a callback that returns a promise makes zod raise $ZodAsyncError rather than
|
|
60
|
+
* silently accepting. Because the ref points at zod's superRefine WRAPPER, not
|
|
61
|
+
* the user's function, an async callback cannot be detected while extracting —
|
|
62
|
+
* the returned thenable is the only evidence, so the test lives here. Sync
|
|
63
|
+
* callbacks return undefined, so the guard short-circuits on the first operand.
|
|
64
|
+
*/
|
|
65
|
+
export declare const ZC_SR_RUN_DECL: string;
|
|
66
|
+
/**
|
|
67
|
+
* superRefine slow-path merge: run the callback, then move its issues onto the
|
|
68
|
+
* validator's list the way zod's finalizeIssue does — the node's path prefixed
|
|
69
|
+
* onto any path the user supplied, and the internal `inst`/`continue` fields
|
|
70
|
+
* dropped (they are zod bookkeeping, deleted before the issue is user-visible).
|
|
71
|
+
*
|
|
72
|
+
* Returns the payload, so the caller can write `.value` back (the callback may
|
|
73
|
+
* have rewritten it) and read `.aborted`. Aborted is set when any issue aborts
|
|
74
|
+
* in zod's sense (`continue !== true`, which covers `fatal: true` and the string
|
|
75
|
+
* shorthand, whose issue carries no `continue` at all) — or when the callback
|
|
76
|
+
* set it directly, also public payload API. A union option uses it to mark
|
|
77
|
+
* itself aborted, matching how zod prunes option errors; without it an option
|
|
78
|
+
* failing only through superRefine would be surfaced directly instead of inside
|
|
79
|
+
* `invalid_union`.
|
|
80
|
+
*/
|
|
81
|
+
export declare const ZC_SR_DECL: string;
|
|
37
82
|
/** Non-issue runtime helper declarations hosted in the virtual module. */
|
|
38
83
|
export declare const RUNTIME_HELPER_DECLS: Readonly<Record<string, string>>;
|
|
39
84
|
//# sourceMappingURL=issue-decls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-decls.d.ts","sourceRoot":"","sources":["../../../src/core/codegen/issue-decls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA0BH,6DAA6D;AAC7D,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,gYACmV,CAAC;AAE5W;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,mDAAmD,CAAC;AAE5E,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"issue-decls.d.ts","sourceRoot":"","sources":["../../../src/core/codegen/issue-decls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA0BH,6DAA6D;AAC7D,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASxD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,gYACmV,CAAC;AAE5W;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,mDAAmD,CAAC;AAE5E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,QAEmB,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,QAEiD,CAAC;AAE7E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,QAKkD,CAAC;AAE1E,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKjE,CAAC"}
|
|
@@ -51,9 +51,62 @@ export const ZC_FSR_DECL = 'function __zcFsr(v,s){var vd=((""+v).split(".")[1]||
|
|
|
51
51
|
* per call would not.
|
|
52
52
|
*/
|
|
53
53
|
export const ZC_HOP_DECL = "const __zcHop=Object.prototype.hasOwnProperty;";
|
|
54
|
+
/**
|
|
55
|
+
* superRefine fast-check: run the payload callback on a throwaway payload and
|
|
56
|
+
* report whether it both added nothing AND left the value alone. zod's own
|
|
57
|
+
* wrapper (the referenced function) installs `addIssue` and normalizes what the
|
|
58
|
+
* user adds, so the verdict is zod's; the issues themselves are re-collected by
|
|
59
|
+
* the slow walk.
|
|
60
|
+
*
|
|
61
|
+
* The `p.value===v` half is what lets a superRefine node keep a fast path at
|
|
62
|
+
* all. `value` is writable public API ($RefinementCtx extends ParsePayload), so
|
|
63
|
+
* a callback may rewrite it, and the fast path's caller returns the ORIGINAL
|
|
64
|
+
* input on success — which would then be stale. Reporting false when the value
|
|
65
|
+
* moved routes those parses into the slow walk, which propagates the new value
|
|
66
|
+
* (see ZC_SR_DECL). Callbacks that only validate — effectively all of them —
|
|
67
|
+
* still take the fast exit.
|
|
68
|
+
*/
|
|
69
|
+
export const ZC_SR_OK_DECL = "function __zcSrOk(f,v){var p={value:v,issues:[]};__zcSrRun(f,p);" +
|
|
70
|
+
"return p.issues.length===0&&p.value===v;}";
|
|
71
|
+
/**
|
|
72
|
+
* Module-local (never imported by generated code) — __zcSr/__zcSrOk call it.
|
|
73
|
+
* Lean mode declares it in the runtime module beside them; inline mode pushes it
|
|
74
|
+
* into the preamble alongside whichever of the two is used.
|
|
75
|
+
*
|
|
76
|
+
* Invoke the referenced wrapper, reproducing zod's synchronous-parse contract:
|
|
77
|
+
* a callback that returns a promise makes zod raise $ZodAsyncError rather than
|
|
78
|
+
* silently accepting. Because the ref points at zod's superRefine WRAPPER, not
|
|
79
|
+
* the user's function, an async callback cannot be detected while extracting —
|
|
80
|
+
* the returned thenable is the only evidence, so the test lives here. Sync
|
|
81
|
+
* callbacks return undefined, so the guard short-circuits on the first operand.
|
|
82
|
+
*/
|
|
83
|
+
export const ZC_SR_RUN_DECL = "function __zcSrRun(f,p){var r=f(p);" +
|
|
84
|
+
'if(r&&typeof r.then==="function"){throw new __zcCore.$ZodAsyncError();}}';
|
|
85
|
+
/**
|
|
86
|
+
* superRefine slow-path merge: run the callback, then move its issues onto the
|
|
87
|
+
* validator's list the way zod's finalizeIssue does — the node's path prefixed
|
|
88
|
+
* onto any path the user supplied, and the internal `inst`/`continue` fields
|
|
89
|
+
* dropped (they are zod bookkeeping, deleted before the issue is user-visible).
|
|
90
|
+
*
|
|
91
|
+
* Returns the payload, so the caller can write `.value` back (the callback may
|
|
92
|
+
* have rewritten it) and read `.aborted`. Aborted is set when any issue aborts
|
|
93
|
+
* in zod's sense (`continue !== true`, which covers `fatal: true` and the string
|
|
94
|
+
* shorthand, whose issue carries no `continue` at all) — or when the callback
|
|
95
|
+
* set it directly, also public payload API. A union option uses it to mark
|
|
96
|
+
* itself aborted, matching how zod prunes option errors; without it an option
|
|
97
|
+
* failing only through superRefine would be surfaced directly instead of inside
|
|
98
|
+
* `invalid_union`.
|
|
99
|
+
*/
|
|
100
|
+
export const ZC_SR_DECL = "function __zcSr(f,v,p,e){var q={value:v,issues:[]};__zcSrRun(f,q);" +
|
|
101
|
+
"for(var i=0;i<q.issues.length;i++){var s=q.issues[i],t={};" +
|
|
102
|
+
'for(var k in s){if(k!=="inst"&&k!=="continue")t[k]=s[k];}' +
|
|
103
|
+
"if(s.continue!==true)q.aborted=true;" +
|
|
104
|
+
"t.path=s.path&&s.path.length?p.concat(s.path):p;e.push(t);}return q;}";
|
|
54
105
|
/** Non-issue runtime helper declarations hosted in the virtual module. */
|
|
55
106
|
export const RUNTIME_HELPER_DECLS = {
|
|
56
107
|
__zcFsr: ZC_FSR_DECL,
|
|
57
108
|
__zcHop: ZC_HOP_DECL,
|
|
109
|
+
__zcSr: ZC_SR_DECL,
|
|
110
|
+
__zcSrOk: ZC_SR_OK_DECL,
|
|
58
111
|
};
|
|
59
112
|
//# sourceMappingURL=issue-decls.js.map
|