zodvex 0.7.4-beta.0 → 0.7.4
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/dist/internal/init.d.ts +8 -19
- package/dist/internal/init.d.ts.map +1 -1
- package/dist/mini/server/index.js.map +1 -1
- package/dist/public/server/index.d.ts +1 -1
- package/dist/public/server/index.d.ts.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/src/internal/init.ts +9 -33
- package/src/public/server/index.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zodvex",
|
|
3
|
-
"version": "0.7.4
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Codec-first Zod v4 integration for Convex -- type-safe validation, encoding, DB wrapping, and codegen.",
|
|
5
5
|
"keywords": ["zod", "convex", "validators", "codec", "mapping", "schema", "validation"],
|
|
6
6
|
"homepage": "https://github.com/panzacoder/zodvex#readme",
|
package/src/internal/init.ts
CHANGED
|
@@ -94,11 +94,11 @@ type ResolvedCustomArgs<ZArgs extends ZodValidator> =
|
|
|
94
94
|
* and the resulting function registers the wire validator. See #72.
|
|
95
95
|
*
|
|
96
96
|
* For a reusable, standalone customization, author it with {@link defineContext}
|
|
97
|
-
* (full inference, zero annotations)
|
|
98
|
-
*
|
|
99
|
-
*
|
|
97
|
+
* (full inference, zero annotations) — a bare object literal has no contextual
|
|
98
|
+
* type, so its `input` params would otherwise need hand-annotations that drift
|
|
99
|
+
* from this type.
|
|
100
100
|
*/
|
|
101
|
-
export type
|
|
101
|
+
export type ZodvexCustomization<
|
|
102
102
|
InputCtx,
|
|
103
103
|
ZArgs extends ZodValidator,
|
|
104
104
|
CustomCtx extends Record<string, any>,
|
|
@@ -144,7 +144,7 @@ export type ZodvexBuilder<
|
|
|
144
144
|
CustomMadeArgs extends Record<string, any> = Record<string, never>,
|
|
145
145
|
ExtraArgs extends Record<string, any> = Record<string, any>
|
|
146
146
|
>(
|
|
147
|
-
customization:
|
|
147
|
+
customization: ZodvexCustomization<
|
|
148
148
|
Overwrite<InputCtx, CodecCtx>,
|
|
149
149
|
ZArgs,
|
|
150
150
|
CustomCtx,
|
|
@@ -174,25 +174,6 @@ type InputCtxOf<B extends AnyZodvexBuilder> =
|
|
|
174
174
|
? Overwrite<InputCtx, CodecCtx>
|
|
175
175
|
: never
|
|
176
176
|
|
|
177
|
-
/**
|
|
178
|
-
* The shape of a `.withContext()` customization for a builder, as a **type** to
|
|
179
|
-
* annotate with: `const c: ZodvexCustomization<typeof zm> = { … }`.
|
|
180
|
-
*
|
|
181
|
-
* It pins the builder's input ctx so `input`'s `ctx`/`args` are contextually typed
|
|
182
|
-
* (no hand-annotation). A type annotation can't *infer* the output generics
|
|
183
|
-
* (`CustomCtx` etc.) from the value, so they default permissively here — meaning a
|
|
184
|
-
* customization that adds ctx fields the handler later reads should use
|
|
185
|
-
* {@link defineContext} (which infers them) rather than this alias. Reach for this
|
|
186
|
-
* when the customization adds no ctx, or re-types what it adds explicitly.
|
|
187
|
-
*/
|
|
188
|
-
export type ZodvexCustomization<
|
|
189
|
-
B extends AnyZodvexBuilder,
|
|
190
|
-
ZArgs extends ZodValidator = Record<string, never>,
|
|
191
|
-
CustomCtx extends Record<string, any> = Record<string, any>,
|
|
192
|
-
CustomMadeArgs extends Record<string, any> = Record<string, never>,
|
|
193
|
-
ExtraArgs extends Record<string, any> = Record<string, any>
|
|
194
|
-
> = ZodWithContextCustomization<InputCtxOf<B>, ZArgs, CustomCtx, CustomMadeArgs, ExtraArgs>
|
|
195
|
-
|
|
196
177
|
/**
|
|
197
178
|
* Author a reusable `.withContext()` customization with full type inference.
|
|
198
179
|
*
|
|
@@ -206,7 +187,8 @@ export type ZodvexCustomization<
|
|
|
206
187
|
* inferred (zero annotations);
|
|
207
188
|
* - the output generics (`CustomCtx` / `CustomMadeArgs` / `ExtraArgs`) are inferred
|
|
208
189
|
* from your `input`'s return, so the handler downstream still sees the precise
|
|
209
|
-
* merged ctx (which a
|
|
190
|
+
* merged ctx (which a standalone type annotation cannot do — only inference from
|
|
191
|
+
* the value, via this function, preserves it).
|
|
210
192
|
*
|
|
211
193
|
* The result carries no visibility, so it feeds **both** same-kind builders — pass
|
|
212
194
|
* either (`zm`/`zim`, `za`/`zia`, `zq`/`ziq` share the input ctx):
|
|
@@ -231,14 +213,8 @@ export function defineContext<
|
|
|
231
213
|
ExtraArgs extends Record<string, any> = Record<string, any>
|
|
232
214
|
>(
|
|
233
215
|
_builder: B,
|
|
234
|
-
customization:
|
|
235
|
-
|
|
236
|
-
ZArgs,
|
|
237
|
-
CustomCtx,
|
|
238
|
-
CustomMadeArgs,
|
|
239
|
-
ExtraArgs
|
|
240
|
-
>
|
|
241
|
-
): ZodWithContextCustomization<InputCtxOf<B>, ZArgs, CustomCtx, CustomMadeArgs, ExtraArgs> {
|
|
216
|
+
customization: ZodvexCustomization<InputCtxOf<B>, ZArgs, CustomCtx, CustomMadeArgs, ExtraArgs>
|
|
217
|
+
): ZodvexCustomization<InputCtxOf<B>, ZArgs, CustomCtx, CustomMadeArgs, ExtraArgs> {
|
|
242
218
|
return customization
|
|
243
219
|
}
|
|
244
220
|
|
|
@@ -55,8 +55,7 @@ export {
|
|
|
55
55
|
type ZodvexBuilder,
|
|
56
56
|
type ZodvexCustomization,
|
|
57
57
|
type ZodvexMutationCtx,
|
|
58
|
-
type ZodvexQueryCtx
|
|
59
|
-
type ZodWithContextCustomization
|
|
58
|
+
type ZodvexQueryCtx
|
|
60
59
|
} from '../../internal/init'
|
|
61
60
|
// Rule and audit types for .withRules() and .audit()
|
|
62
61
|
//
|