zodvex 0.2.0 → 0.2.2
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 +366 -380
- package/dist/index.d.mts +218 -82
- package/dist/index.d.ts +218 -82
- package/dist/index.js +125 -205
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -192
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/builders.ts +310 -0
- package/src/custom.ts +4 -84
- package/src/index.ts +4 -1
- package/src/mapping/core.ts +16 -0
- package/src/tables.ts +34 -32
- package/src/utils.ts +9 -6
- package/src/wrappers.ts +60 -52
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Customization } from 'convex-helpers/server/customFunctions';
|
|
2
|
+
export { customCtx } from 'convex-helpers/server/customFunctions';
|
|
3
|
+
import * as convex_server from 'convex/server';
|
|
4
|
+
import { RegisteredQuery, RegisteredMutation, RegisteredAction, DefaultFunctionArgs, FunctionVisibility, ArgsArrayToObject, GenericDataModel, QueryBuilder, GenericQueryCtx } from 'convex/server';
|
|
2
5
|
import * as convex_values from 'convex/values';
|
|
3
6
|
import { VAny, VOptional, VUnion, VId, GenericId, VString, VFloat64, VInt64, VBoolean, VNull, VArray, VObject, VLiteral, VRecord, PropertyValidators } from 'convex/values';
|
|
4
|
-
import
|
|
5
|
-
import { RegisteredQuery, RegisteredMutation, RegisteredAction, DefaultFunctionArgs, FunctionVisibility, ArgsArrayToObject, GenericDataModel, QueryBuilder, GenericQueryCtx, MutationBuilder, GenericMutationCtx, ActionBuilder, GenericActionCtx } from 'convex/server';
|
|
6
|
-
import { Customization } from 'convex-helpers/server/customFunctions';
|
|
7
|
+
import { z } from 'zod';
|
|
7
8
|
import * as convex_helpers from 'convex-helpers';
|
|
8
9
|
|
|
9
|
-
type ConvexCodec<T> = {
|
|
10
|
-
validator: any;
|
|
11
|
-
encode: (value: T) => any;
|
|
12
|
-
decode: (value: any) => T;
|
|
13
|
-
pick: <K extends keyof T>(keys: K[]) => ConvexCodec<Pick<T, K>>;
|
|
14
|
-
};
|
|
15
|
-
declare function convexCodec<T>(schema: z.ZodType<T>): ConvexCodec<T>;
|
|
16
|
-
declare function toConvexJS(schema?: any, value?: any): any;
|
|
17
|
-
declare function fromConvexJS(value: any, schema: any): any;
|
|
18
|
-
|
|
19
10
|
type IsZid<T> = T extends {
|
|
20
11
|
_tableName: infer _TableName extends string;
|
|
21
12
|
} ? true : false;
|
|
@@ -147,14 +138,189 @@ type CustomBuilder<FuncType extends 'query' | 'mutation' | 'action', CustomArgsV
|
|
|
147
138
|
(ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<ArgsOutput<ArgsValidator>, CustomMadeArgs>): ReturnValue;
|
|
148
139
|
}): Registration<FuncType, Visibility, ArgsArrayToObject<CustomArgsValidator extends Record<string, never> ? ArgsInput<ArgsValidator> : ArgsInput<ArgsValidator> extends [infer A] ? [Expand<A & convex_values.ObjectType<CustomArgsValidator>>] : [convex_values.ObjectType<CustomArgsValidator>]>, ReturnsZodValidator extends void ? ReturnValue : ReturnValueOutput<ReturnsZodValidator>>;
|
|
149
140
|
};
|
|
141
|
+
declare function customFnBuilder<Ctx extends Record<string, any>, Builder extends (fn: any) => any, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, ExtraArgs extends Record<string, any> = Record<string, any>>(builder: Builder, customization: Customization<Ctx, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): (fn: any) => any;
|
|
150
142
|
declare function zCustomQuery<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record<string, any> = Record<string, any>>(query: QueryBuilder<DataModel, Visibility>, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'query', CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericQueryCtx<DataModel>, Visibility, ExtraArgs>;
|
|
151
143
|
declare function zCustomQuery<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility, ExtraArgs extends Record<string, any> = Record<string, any>>(query: QueryBuilder<any, Visibility>, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'query', CustomArgsValidator, CustomCtx, CustomMadeArgs, any, Visibility, ExtraArgs>;
|
|
152
|
-
declare function zStrictQuery<Builder extends (fn: any) => any, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility = ExtractVisibility<Builder>, ExtraArgs extends Record<string, any> = Record<string, any>>(query: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'query', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
153
|
-
declare function zStrictMutation<Builder extends (fn: any) => any, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility = ExtractVisibility<Builder>, ExtraArgs extends Record<string, any> = Record<string, any>>(mutation: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'mutation', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
154
|
-
declare function zStrictAction<Builder extends (fn: any) => any, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility = ExtractVisibility<Builder>, ExtraArgs extends Record<string, any> = Record<string, any>>(action: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'action', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
155
144
|
declare function zCustomMutation<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Builder extends (fn: any) => any, Visibility extends FunctionVisibility = 'public', ExtraArgs extends Record<string, any> = Record<string, any>>(mutation: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'mutation', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
156
145
|
declare function zCustomAction<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Builder extends (fn: any) => any, Visibility extends FunctionVisibility = 'public', ExtraArgs extends Record<string, any> = Record<string, any>>(action: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'action', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
157
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Creates a reusable query builder from a Convex query builder.
|
|
149
|
+
* Returns a builder function that accepts Convex-style config objects with args, handler, and returns.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { query } from './_generated/server'
|
|
154
|
+
* import { zQueryBuilder } from 'zodvex'
|
|
155
|
+
*
|
|
156
|
+
* // Create a reusable builder
|
|
157
|
+
* export const zq = zQueryBuilder(query)
|
|
158
|
+
*
|
|
159
|
+
* // Use it with Convex-style object syntax
|
|
160
|
+
* export const getUser = zq({
|
|
161
|
+
* args: { id: z.string() },
|
|
162
|
+
* handler: async (ctx, { id }) => {
|
|
163
|
+
* return ctx.db.get(id)
|
|
164
|
+
* }
|
|
165
|
+
* })
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
declare function zQueryBuilder<Builder extends (fn: any) => any>(builder: Builder): <A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined, Visibility extends FunctionVisibility = ExtractVisibility<Builder>>(config: {
|
|
169
|
+
args?: A;
|
|
170
|
+
handler: (ctx: ExtractCtx<Builder>, args: ZodToConvexArgs<A extends undefined ? Record<string, never> : A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>;
|
|
171
|
+
returns?: R;
|
|
172
|
+
}) => RegisteredQuery<Visibility, ZodToConvexArgs<A extends undefined ? Record<string, never> : A>, Promise<InferReturns<R>>>;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a reusable mutation builder from a Convex mutation builder.
|
|
175
|
+
* Returns a builder function that accepts Convex-style config objects with args, handler, and returns.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* import { mutation } from './_generated/server'
|
|
180
|
+
* import { zMutationBuilder } from 'zodvex'
|
|
181
|
+
*
|
|
182
|
+
* // Create a reusable builder
|
|
183
|
+
* export const zm = zMutationBuilder(mutation)
|
|
184
|
+
*
|
|
185
|
+
* // Use it with Convex-style object syntax
|
|
186
|
+
* export const updateUser = zm({
|
|
187
|
+
* args: { id: z.string(), name: z.string() },
|
|
188
|
+
* handler: async (ctx, { id, name }) => {
|
|
189
|
+
* return ctx.db.patch(id, { name })
|
|
190
|
+
* }
|
|
191
|
+
* })
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
declare function zMutationBuilder<Builder extends (fn: any) => any>(builder: Builder): <A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined, Visibility extends FunctionVisibility = ExtractVisibility<Builder>>(config: {
|
|
195
|
+
args?: A;
|
|
196
|
+
handler: (ctx: ExtractCtx<Builder>, args: ZodToConvexArgs<A extends undefined ? Record<string, never> : A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>;
|
|
197
|
+
returns?: R;
|
|
198
|
+
}) => RegisteredMutation<Visibility, ZodToConvexArgs<A extends undefined ? Record<string, never> : A>, Promise<InferReturns<R>>>;
|
|
199
|
+
/**
|
|
200
|
+
* Creates a reusable action builder from a Convex action builder.
|
|
201
|
+
* Returns a builder function that accepts Convex-style config objects with args, handler, and returns.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* import { action } from './_generated/server'
|
|
206
|
+
* import { zActionBuilder } from 'zodvex'
|
|
207
|
+
*
|
|
208
|
+
* // Create a reusable builder
|
|
209
|
+
* export const za = zActionBuilder(action)
|
|
210
|
+
*
|
|
211
|
+
* // Use it with Convex-style object syntax
|
|
212
|
+
* export const sendEmail = za({
|
|
213
|
+
* args: { to: z.string().email(), subject: z.string() },
|
|
214
|
+
* handler: async (ctx, { to, subject }) => {
|
|
215
|
+
* // Send email
|
|
216
|
+
* }
|
|
217
|
+
* })
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
declare function zActionBuilder<Builder extends (fn: any) => any>(builder: Builder): <A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined, Visibility extends FunctionVisibility = ExtractVisibility<Builder>>(config: {
|
|
221
|
+
args?: A;
|
|
222
|
+
handler: (ctx: ExtractCtx<Builder>, args: ZodToConvexArgs<A extends undefined ? Record<string, never> : A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>;
|
|
223
|
+
returns?: R;
|
|
224
|
+
}) => RegisteredAction<Visibility, ZodToConvexArgs<A extends undefined ? Record<string, never> : A>, Promise<InferReturns<R>>>;
|
|
225
|
+
/**
|
|
226
|
+
* Creates a custom query builder with context injection from a Convex query builder.
|
|
227
|
+
* Allows you to add custom context (like auth, permissions, etc.) to your queries.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* import { query } from './_generated/server'
|
|
232
|
+
* import { zCustomQueryBuilder, customCtx } from 'zodvex'
|
|
233
|
+
*
|
|
234
|
+
* // Create a builder with auth context
|
|
235
|
+
* export const authQuery = zCustomQueryBuilder(
|
|
236
|
+
* query,
|
|
237
|
+
* customCtx(async (ctx) => {
|
|
238
|
+
* const user = await getUserOrThrow(ctx)
|
|
239
|
+
* return { user }
|
|
240
|
+
* })
|
|
241
|
+
* )
|
|
242
|
+
*
|
|
243
|
+
* // Use it with automatic user injection
|
|
244
|
+
* export const getMyProfile = authQuery({
|
|
245
|
+
* args: {},
|
|
246
|
+
* handler: async (ctx) => {
|
|
247
|
+
* // ctx.user is automatically available
|
|
248
|
+
* return ctx.db.get(ctx.user._id)
|
|
249
|
+
* }
|
|
250
|
+
* })
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
declare function zCustomQueryBuilder<Builder extends (fn: any) => any, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility = ExtractVisibility<Builder>, ExtraArgs extends Record<string, any> = Record<string, any>>(query: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'query', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
254
|
+
/**
|
|
255
|
+
* Creates a custom mutation builder with context injection from a Convex mutation builder.
|
|
256
|
+
* Allows you to add custom context (like auth, permissions, etc.) to your mutations.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* import { mutation } from './_generated/server'
|
|
261
|
+
* import { zCustomMutationBuilder, customCtx } from 'zodvex'
|
|
262
|
+
*
|
|
263
|
+
* // Create a builder with auth context
|
|
264
|
+
* export const authMutation = zCustomMutationBuilder(
|
|
265
|
+
* mutation,
|
|
266
|
+
* customCtx(async (ctx) => {
|
|
267
|
+
* const user = await getUserOrThrow(ctx)
|
|
268
|
+
* return { user }
|
|
269
|
+
* })
|
|
270
|
+
* )
|
|
271
|
+
*
|
|
272
|
+
* // Use it with automatic user injection
|
|
273
|
+
* export const updateProfile = authMutation({
|
|
274
|
+
* args: { name: z.string() },
|
|
275
|
+
* handler: async (ctx, { name }) => {
|
|
276
|
+
* // ctx.user is automatically available
|
|
277
|
+
* await ctx.db.patch(ctx.user._id, { name })
|
|
278
|
+
* }
|
|
279
|
+
* })
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
declare function zCustomMutationBuilder<Builder extends (fn: any) => any, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility = ExtractVisibility<Builder>, ExtraArgs extends Record<string, any> = Record<string, any>>(mutation: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'mutation', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
283
|
+
/**
|
|
284
|
+
* Creates a custom action builder with context injection from a Convex action builder.
|
|
285
|
+
* Allows you to add custom context (like auth, permissions, etc.) to your actions.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* import { action } from './_generated/server'
|
|
290
|
+
* import { zCustomActionBuilder, customCtx } from 'zodvex'
|
|
291
|
+
*
|
|
292
|
+
* // Create a builder with auth context
|
|
293
|
+
* export const authAction = zCustomActionBuilder(
|
|
294
|
+
* action,
|
|
295
|
+
* customCtx(async (ctx) => {
|
|
296
|
+
* const identity = await ctx.auth.getUserIdentity()
|
|
297
|
+
* if (!identity) throw new Error('Unauthorized')
|
|
298
|
+
* return { userId: identity.subject }
|
|
299
|
+
* })
|
|
300
|
+
* )
|
|
301
|
+
*
|
|
302
|
+
* // Use it with automatic auth injection
|
|
303
|
+
* export const sendEmail = authAction({
|
|
304
|
+
* args: { to: z.string().email() },
|
|
305
|
+
* handler: async (ctx, { to }) => {
|
|
306
|
+
* // ctx.userId is automatically available
|
|
307
|
+
* await sendEmailService(to, ctx.userId)
|
|
308
|
+
* }
|
|
309
|
+
* })
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
declare function zCustomActionBuilder<Builder extends (fn: any) => any, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility = ExtractVisibility<Builder>, ExtraArgs extends Record<string, any> = Record<string, any>>(action: Builder, customization: Customization<any, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<'action', CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtractCtx<Builder>, Visibility, ExtraArgs>;
|
|
313
|
+
|
|
314
|
+
type ConvexCodec<T> = {
|
|
315
|
+
validator: any;
|
|
316
|
+
encode: (value: T) => any;
|
|
317
|
+
decode: (value: any) => T;
|
|
318
|
+
pick: <K extends keyof T>(keys: K[]) => ConvexCodec<Pick<T, K>>;
|
|
319
|
+
};
|
|
320
|
+
declare function convexCodec<T>(schema: z.ZodType<T>): ConvexCodec<T>;
|
|
321
|
+
declare function toConvexJS(schema?: any, value?: any): any;
|
|
322
|
+
declare function fromConvexJS(value: any, schema: any): any;
|
|
323
|
+
|
|
158
324
|
type BaseCodec = {
|
|
159
325
|
check: (schema: any) => boolean;
|
|
160
326
|
toValidator: (schema: any) => any;
|
|
@@ -186,7 +352,29 @@ declare function zodDocOrNull<TableName extends string, Shape extends z.ZodRawSh
|
|
|
186
352
|
* This architectural decision is important for projects that rely heavily on type safety and
|
|
187
353
|
* developer experience, as it avoids the type erasure that can occur when using ZodObject directly.
|
|
188
354
|
*
|
|
189
|
-
* Returns
|
|
355
|
+
* Returns the Table definition along with Zod schemas for documents and arrays.
|
|
356
|
+
*
|
|
357
|
+
* @param name - The table name
|
|
358
|
+
* @param shape - A raw object mapping field names to Zod validators
|
|
359
|
+
* @returns A Table with attached shape, zDoc schema, and docArray helper
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* const Users = zodTable('users', {
|
|
364
|
+
* name: z.string(),
|
|
365
|
+
* email: z.string().email(),
|
|
366
|
+
* age: z.number().optional()
|
|
367
|
+
* })
|
|
368
|
+
*
|
|
369
|
+
* // Use in schema
|
|
370
|
+
* export default defineSchema({ users: Users.table })
|
|
371
|
+
*
|
|
372
|
+
* // Use for return types
|
|
373
|
+
* export const getUsers = zQuery(query, {},
|
|
374
|
+
* async (ctx) => ctx.db.query('users').collect(),
|
|
375
|
+
* { returns: Users.docArray }
|
|
376
|
+
* )
|
|
377
|
+
* ```
|
|
190
378
|
*/
|
|
191
379
|
declare function zodTable<TableName extends string, Shape extends Record<string, z.ZodTypeAny>>(name: TableName, shape: Shape): {
|
|
192
380
|
name: TableName;
|
|
@@ -238,55 +426,14 @@ declare function zodTable<TableName extends string, Shape extends Record<string,
|
|
|
238
426
|
_id: ReturnType<typeof zid<TableName>>;
|
|
239
427
|
_creationTime: z.ZodNumber;
|
|
240
428
|
}>;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
docSchema: z.ZodObject<{
|
|
245
|
-
_id: z.ZodType<GenericId<TableName>, unknown, z.core.$ZodTypeInternals<GenericId<TableName>, unknown>> & {
|
|
246
|
-
_tableName: TableName;
|
|
247
|
-
};
|
|
248
|
-
_creationTime: z.ZodNumber;
|
|
249
|
-
}, z.core.$strip>;
|
|
250
|
-
docArray: z.ZodArray<z.ZodObject<{
|
|
429
|
+
docArray: z.ZodArray<z.ZodObject<Readonly<{
|
|
430
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
431
|
+
}> & {
|
|
251
432
|
_id: z.ZodType<GenericId<TableName>, unknown, z.core.$ZodTypeInternals<GenericId<TableName>, unknown>> & {
|
|
252
433
|
_tableName: TableName;
|
|
253
434
|
};
|
|
254
435
|
_creationTime: z.ZodNumber;
|
|
255
436
|
}, z.core.$strip>>;
|
|
256
|
-
name: TableName;
|
|
257
|
-
table: convex_server.TableDefinition<convex_values.VObject<{
|
|
258
|
-
[x: string]: any;
|
|
259
|
-
[x: number]: any;
|
|
260
|
-
[x: symbol]: any;
|
|
261
|
-
}, ConvexValidatorFromZodFieldsAuto<any>, "required", string>, {}, {}, {}>;
|
|
262
|
-
doc: convex_values.VObject<{
|
|
263
|
-
[x: string]: any;
|
|
264
|
-
[x: number]: any;
|
|
265
|
-
[x: symbol]: any;
|
|
266
|
-
}, {
|
|
267
|
-
[x: string]: convex_values.VFloat64<number, "required"> | convex_values.VNull<null, "required"> | convex_values.VLiteral<z.core.util.Literal, "required"> | convex_values.VAny<"required", "required", string> | convex_values.VAny<"required", "required", string> | convex_values.VAny<"required", "required", string> | convex_values.VAny<"required", "required", string> | convex_values.VUnion<unknown, any[], "required", any> | convex_values.VUnion<unknown, any[], "required", any> | convex_values.VString<any, "required"> | convex_values.VFloat64<any, "required"> | convex_values.VInt64<any, "required"> | convex_values.VBoolean<any, "required"> | convex_values.VArray<any, convex_values.VAny<"required", "required", string>, "required"> | convex_values.VObject<any, {
|
|
268
|
-
readonly [x: string]: convex_values.VAny<"required", "required", string>;
|
|
269
|
-
}, "required", string> | convex_values.VUnion<z.core.util.EnumValue, any[], "required", any> | convex_values.VRecord<Record<string, unknown>, convex_values.VString<string, "required">, convex_values.VAny<"required", "required", string>, "required", string> | convex_values.VLiteral<z.core.util.Literal, "optional"> | convex_values.VAny<"required" | undefined, "optional", string> | convex_values.VUnion<unknown, any[], "optional", any> | convex_values.VString<any, "optional"> | convex_values.VFloat64<any, "optional"> | convex_values.VFloat64<number, "optional"> | convex_values.VInt64<any, "optional"> | convex_values.VBoolean<any, "optional"> | convex_values.VNull<null, "optional"> | convex_values.VArray<any, convex_values.VAny<"required", "required", string>, "optional"> | convex_values.VObject<any, {
|
|
270
|
-
readonly [x: string]: convex_values.VAny<"required", "required", string>;
|
|
271
|
-
}, "optional", string> | convex_values.VUnion<z.core.util.EnumValue, any[], "optional", any> | convex_values.VRecord<Record<string, unknown>, convex_values.VString<string, "required">, convex_values.VAny<"required", "required", string>, "optional", string>;
|
|
272
|
-
_id: convex_values.VId<GenericId<TableName>, "required">;
|
|
273
|
-
_creationTime: convex_values.VFloat64<number, "required">;
|
|
274
|
-
}, "required", string>;
|
|
275
|
-
withoutSystemFields: ConvexValidatorFromZodFieldsAuto<any>;
|
|
276
|
-
withSystemFields: {
|
|
277
|
-
[x: string]: convex_values.VFloat64<number, "required"> | convex_values.VNull<null, "required"> | convex_values.VLiteral<z.core.util.Literal, "required"> | convex_values.VAny<"required", "required", string> | convex_values.VAny<"required", "required", string> | convex_values.VAny<"required", "required", string> | convex_values.VAny<"required", "required", string> | convex_values.VUnion<unknown, any[], "required", any> | convex_values.VUnion<unknown, any[], "required", any> | convex_values.VString<any, "required"> | convex_values.VFloat64<any, "required"> | convex_values.VInt64<any, "required"> | convex_values.VBoolean<any, "required"> | convex_values.VArray<any, convex_values.VAny<"required", "required", string>, "required"> | convex_values.VObject<any, {
|
|
278
|
-
readonly [x: string]: convex_values.VAny<"required", "required", string>;
|
|
279
|
-
}, "required", string> | convex_values.VUnion<z.core.util.EnumValue, any[], "required", any> | convex_values.VRecord<Record<string, unknown>, convex_values.VString<string, "required">, convex_values.VAny<"required", "required", string>, "required", string> | convex_values.VLiteral<z.core.util.Literal, "optional"> | convex_values.VAny<"required" | undefined, "optional", string> | convex_values.VUnion<unknown, any[], "optional", any> | convex_values.VString<any, "optional"> | convex_values.VFloat64<any, "optional"> | convex_values.VFloat64<number, "optional"> | convex_values.VInt64<any, "optional"> | convex_values.VBoolean<any, "optional"> | convex_values.VNull<null, "optional"> | convex_values.VArray<any, convex_values.VAny<"required", "required", string>, "optional"> | convex_values.VObject<any, {
|
|
280
|
-
readonly [x: string]: convex_values.VAny<"required", "required", string>;
|
|
281
|
-
}, "optional", string> | convex_values.VUnion<z.core.util.EnumValue, any[], "optional", any> | convex_values.VRecord<Record<string, unknown>, convex_values.VString<string, "required">, convex_values.VAny<"required", "required", string>, "optional", string>;
|
|
282
|
-
_id: convex_values.VId<GenericId<TableName>, "required">;
|
|
283
|
-
_creationTime: convex_values.VFloat64<number, "required">;
|
|
284
|
-
};
|
|
285
|
-
systemFields: {
|
|
286
|
-
_id: convex_values.VId<GenericId<TableName>, "required">;
|
|
287
|
-
_creationTime: convex_values.VFloat64<number, "required">;
|
|
288
|
-
};
|
|
289
|
-
_id: convex_values.VId<GenericId<TableName>, "required">;
|
|
290
437
|
};
|
|
291
438
|
|
|
292
439
|
declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
@@ -314,27 +461,16 @@ declare function zPaginated<T extends z.ZodTypeAny>(item: T): z.ZodObject<{
|
|
|
314
461
|
*/
|
|
315
462
|
declare function mapDateFieldToNumber(field: z.ZodTypeAny): z.ZodTypeAny;
|
|
316
463
|
type Mask = readonly string[] | Record<string, boolean | 1 | true>;
|
|
464
|
+
/**
|
|
465
|
+
* Returns a plain shape object containing only the selected fields.
|
|
466
|
+
* Accepts either a ZodObject or a raw shape object.
|
|
467
|
+
*/
|
|
317
468
|
declare function pickShape(schemaOrShape: z.ZodObject<any> | Record<string, any>, mask: Mask): Record<string, any>;
|
|
318
469
|
declare function safePick(schema: z.ZodObject<any>, mask: Mask): z.ZodObject<any>;
|
|
470
|
+
/**
|
|
471
|
+
* Convenience: omit a set of keys by building the complement.
|
|
472
|
+
* Avoids using Zod's .omit() which can cause type depth issues.
|
|
473
|
+
*/
|
|
319
474
|
declare function safeOmit(schema: z.ZodObject<any>, mask: Mask): z.ZodObject<any>;
|
|
320
475
|
|
|
321
|
-
|
|
322
|
-
returns?: R;
|
|
323
|
-
}): RegisteredQuery<Visibility, ZodToConvexArgs<A>, Promise<InferReturns<R>>>;
|
|
324
|
-
declare function zInternalQuery<DataModel extends GenericDataModel, Visibility extends FunctionVisibility, A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined>(internalQuery: QueryBuilder<DataModel, Visibility>, input: A, handler: (ctx: GenericQueryCtx<DataModel>, args: ZodToConvexArgs<A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>, options?: {
|
|
325
|
-
returns?: R;
|
|
326
|
-
}): RegisteredQuery<Visibility, ZodToConvexArgs<A>, Promise<InferReturns<R>>>;
|
|
327
|
-
declare function zMutation<DataModel extends GenericDataModel, Visibility extends FunctionVisibility, A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined>(mutation: MutationBuilder<DataModel, Visibility>, input: A, handler: (ctx: GenericMutationCtx<DataModel>, args: ZodToConvexArgs<A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>, options?: {
|
|
328
|
-
returns?: R;
|
|
329
|
-
}): RegisteredMutation<Visibility, ZodToConvexArgs<A>, Promise<InferReturns<R>>>;
|
|
330
|
-
declare function zInternalMutation<DataModel extends GenericDataModel, Visibility extends FunctionVisibility, A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined>(internalMutation: MutationBuilder<DataModel, Visibility>, input: A, handler: (ctx: GenericMutationCtx<DataModel>, args: ZodToConvexArgs<A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>, options?: {
|
|
331
|
-
returns?: R;
|
|
332
|
-
}): RegisteredMutation<Visibility, ZodToConvexArgs<A>, Promise<InferReturns<R>>>;
|
|
333
|
-
declare function zAction<DataModel extends GenericDataModel, Visibility extends FunctionVisibility, A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined>(action: ActionBuilder<DataModel, Visibility>, input: A, handler: (ctx: GenericActionCtx<DataModel>, args: ZodToConvexArgs<A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>, options?: {
|
|
334
|
-
returns?: R;
|
|
335
|
-
}): RegisteredAction<Visibility, ZodToConvexArgs<A>, Promise<InferReturns<R>>>;
|
|
336
|
-
declare function zInternalAction<DataModel extends GenericDataModel, Visibility extends FunctionVisibility, A extends z.ZodTypeAny | Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny | undefined = undefined>(internalAction: ActionBuilder<DataModel, Visibility>, input: A, handler: (ctx: GenericActionCtx<DataModel>, args: ZodToConvexArgs<A>) => InferHandlerReturns<R> | Promise<InferHandlerReturns<R>>, options?: {
|
|
337
|
-
returns?: R;
|
|
338
|
-
}): RegisteredAction<Visibility, ZodToConvexArgs<A>, Promise<InferReturns<R>>>;
|
|
339
|
-
|
|
340
|
-
export { type ConvexCodec, type ConvexValidatorFromZod, type ConvexValidatorFromZodFieldsAuto, type CustomBuilder, type ExtractCtx, type ExtractVisibility, type InferArgs, type InferHandlerReturns, type InferReturns, type PreserveReturnType, type Zid, type ZodToConvexArgs, type ZodValidator, convexCodec, findBaseCodec, formatZodIssues, fromConvexJS, getObjectShape, handleZodValidationError, isDateSchema, makeUnion, mapDateFieldToNumber, pick, pickShape, registerBaseCodec, registryHelpers, returnsAs, safeOmit, safePick, toConvexJS, zAction, zCustomAction, zCustomMutation, zCustomQuery, zInternalAction, zInternalMutation, zInternalQuery, zMutation, zPaginated, zQuery, zStrictAction, zStrictMutation, zStrictQuery, zid, zodDoc, zodDocOrNull, zodTable, zodTableWithDocs, zodToConvex, zodToConvexFields };
|
|
476
|
+
export { type ConvexCodec, type ConvexValidatorFromZod, type ConvexValidatorFromZodFieldsAuto, type CustomBuilder, type ExtractCtx, type ExtractVisibility, type InferArgs, type InferHandlerReturns, type InferReturns, type PreserveReturnType, type Zid, type ZodToConvexArgs, type ZodValidator, convexCodec, customFnBuilder, findBaseCodec, formatZodIssues, fromConvexJS, getObjectShape, handleZodValidationError, isDateSchema, makeUnion, mapDateFieldToNumber, pick, pickShape, registerBaseCodec, registryHelpers, returnsAs, safeOmit, safePick, toConvexJS, zActionBuilder, zCustomAction, zCustomActionBuilder, zCustomMutation, zCustomMutationBuilder, zCustomQuery, zCustomQueryBuilder, zMutationBuilder, zPaginated, zQueryBuilder, zid, zodDoc, zodDocOrNull, zodTable, zodToConvex, zodToConvexFields };
|