kitcn 0.0.1 → 0.12.1

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.
Files changed (93) hide show
  1. package/bin/intent.js +3 -0
  2. package/dist/aggregate/index.d.ts +388 -0
  3. package/dist/aggregate/index.js +37 -0
  4. package/dist/api-entry-BckXqaLb.js +66 -0
  5. package/dist/auth/client/index.d.ts +37 -0
  6. package/dist/auth/client/index.js +217 -0
  7. package/dist/auth/config/index.d.ts +45 -0
  8. package/dist/auth/config/index.js +24 -0
  9. package/dist/auth/generated/index.d.ts +2 -0
  10. package/dist/auth/generated/index.js +3 -0
  11. package/dist/auth/http/index.d.ts +64 -0
  12. package/dist/auth/http/index.js +461 -0
  13. package/dist/auth/index.d.ts +221 -0
  14. package/dist/auth/index.js +1398 -0
  15. package/dist/auth/nextjs/index.d.ts +50 -0
  16. package/dist/auth/nextjs/index.js +81 -0
  17. package/dist/auth-store-Cljlmdmi.js +197 -0
  18. package/dist/builder-CBdG5W6A.js +1974 -0
  19. package/dist/caller-factory-cTXNvYdz.js +216 -0
  20. package/dist/cli.mjs +13264 -0
  21. package/dist/codegen-lF80HSWu.mjs +3416 -0
  22. package/dist/context-utils-HPC5nXzx.d.ts +17 -0
  23. package/dist/create-schema-odyF4kCy.js +156 -0
  24. package/dist/create-schema-orm-DOyiNDCx.js +246 -0
  25. package/dist/crpc/index.d.ts +105 -0
  26. package/dist/crpc/index.js +169 -0
  27. package/dist/customFunctions-C0voKmtx.js +144 -0
  28. package/dist/error-BZEnI7Sq.js +41 -0
  29. package/dist/generated-contract-disabled-Cih4eITO.js +50 -0
  30. package/dist/generated-contract-disabled-D-sOFy92.d.ts +354 -0
  31. package/dist/http-types-DqJubRPJ.d.ts +292 -0
  32. package/dist/meta-utils-0Pu0Nrap.js +117 -0
  33. package/dist/middleware-BUybuv9n.d.ts +34 -0
  34. package/dist/middleware-C2qTZ3V7.js +84 -0
  35. package/dist/orm/index.d.ts +17 -0
  36. package/dist/orm/index.js +10713 -0
  37. package/dist/plugins/index.d.ts +2 -0
  38. package/dist/plugins/index.js +3 -0
  39. package/dist/procedure-caller-DtxLmGwA.d.ts +1467 -0
  40. package/dist/procedure-caller-MWcxhQDv.js +349 -0
  41. package/dist/query-context-B8o6-8kC.js +1518 -0
  42. package/dist/query-context-CFZqIvD7.d.ts +42 -0
  43. package/dist/query-options-Dw7cOyXl.js +121 -0
  44. package/dist/ratelimit/index.d.ts +269 -0
  45. package/dist/ratelimit/index.js +856 -0
  46. package/dist/ratelimit/react/index.d.ts +76 -0
  47. package/dist/ratelimit/react/index.js +183 -0
  48. package/dist/react/index.d.ts +1284 -0
  49. package/dist/react/index.js +2526 -0
  50. package/dist/rsc/index.d.ts +276 -0
  51. package/dist/rsc/index.js +233 -0
  52. package/dist/runtime-CtvJPkur.js +2453 -0
  53. package/dist/server/index.d.ts +5 -0
  54. package/dist/server/index.js +6 -0
  55. package/dist/solid/index.d.ts +1221 -0
  56. package/dist/solid/index.js +2940 -0
  57. package/dist/transformer-DtDhR3Lc.js +194 -0
  58. package/dist/types-BTb_4BaU.d.ts +42 -0
  59. package/dist/types-BiJE7qxR.d.ts +4 -0
  60. package/dist/types-DEJpkIhw.d.ts +88 -0
  61. package/dist/types-HhO_R6pd.d.ts +213 -0
  62. package/dist/validators-B7oIJCAp.js +279 -0
  63. package/dist/validators-vzRKjBJC.d.ts +88 -0
  64. package/dist/watcher.mjs +96 -0
  65. package/dist/where-clause-compiler-DdjN63Io.d.ts +4756 -0
  66. package/package.json +107 -34
  67. package/skills/convex/SKILL.md +486 -0
  68. package/skills/convex/references/features/aggregates.md +353 -0
  69. package/skills/convex/references/features/auth-admin.md +446 -0
  70. package/skills/convex/references/features/auth-organizations.md +1141 -0
  71. package/skills/convex/references/features/auth-polar.md +579 -0
  72. package/skills/convex/references/features/auth.md +470 -0
  73. package/skills/convex/references/features/create-plugins.md +153 -0
  74. package/skills/convex/references/features/http.md +676 -0
  75. package/skills/convex/references/features/migrations.md +162 -0
  76. package/skills/convex/references/features/orm.md +1166 -0
  77. package/skills/convex/references/features/react.md +657 -0
  78. package/skills/convex/references/features/scheduling.md +267 -0
  79. package/skills/convex/references/features/testing.md +209 -0
  80. package/skills/convex/references/setup/auth.md +501 -0
  81. package/skills/convex/references/setup/biome.md +190 -0
  82. package/skills/convex/references/setup/doc-guidelines.md +145 -0
  83. package/skills/convex/references/setup/index.md +761 -0
  84. package/skills/convex/references/setup/next.md +116 -0
  85. package/skills/convex/references/setup/react.md +175 -0
  86. package/skills/convex/references/setup/server.md +473 -0
  87. package/skills/convex/references/setup/start.md +67 -0
  88. package/LICENSE +0 -21
  89. package/README.md +0 -0
  90. package/dist/index.d.mts +0 -5
  91. package/dist/index.d.mts.map +0 -1
  92. package/dist/index.mjs +0 -6
  93. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,1467 @@
1
+ import { t as VRequired } from "./validators-vzRKjBJC.js";
2
+ import { C as HttpProcedure, D as ProcedureMeta, R as getTransformer, S as HttpMethod, c as InferHttpInput, d as CRPCHttpRouter, j as DataTransformerOptions, l as InferHttpOutput, p as HttpRouterRecord, w as HttpProcedureBuilderDef, x as HttpHandlerOpts } from "./http-types-DqJubRPJ.js";
3
+ import { d as Overwrite$1, i as IntersectIfDefined, m as UnsetMarker, o as MiddlewareBuilder, s as MiddlewareFunction, t as AnyMiddleware } from "./types-DEJpkIhw.js";
4
+ import { ConvexError, GenericId, GenericValidator, ObjectType, OptionalProperty, PropertyValidators, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion, Validator } from "convex/values";
5
+ import * as convex_server0 from "convex/server";
6
+ import { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionReference, FunctionReturnType, FunctionVisibility, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, MutationBuilder, QueryBuilder, RegisteredAction, RegisteredMutation, RegisteredQuery, TableNamesInDataModel } from "convex/server";
7
+ import { z } from "zod";
8
+ import * as z$1 from "zod/v4";
9
+ import * as zCore from "zod/v4/core";
10
+
11
+ //#region src/internal/upstream/index.d.ts
12
+ type EmptyObject = Record<string, never>;
13
+ /**
14
+ * Hack! This type causes TypeScript to simplify how it renders object types.
15
+ *
16
+ * It is functionally the identity for object types, but in practice it can
17
+ * simplify expressions like `A & B`.
18
+ */
19
+ type Expand<ObjectType extends Record<any, any>> = ObjectType extends Record<any, any> ? { [Key in keyof ObjectType]: ObjectType[Key] } : never;
20
+ //#endregion
21
+ //#region src/internal/upstream/server/customFunctions.d.ts
22
+ /**
23
+ * A customization of a query, mutation, or action.
24
+ *
25
+ * It can specify common arguments that all defined functions take in,
26
+ * as well as modify the ctx and args arguments to each function.
27
+ *
28
+ * Generally it's defined inline with customQuery, customMutation, etc.
29
+ * But you can define the type explicitly if you want to reuse it.
30
+ *
31
+ * e.g.
32
+ * ```ts
33
+ * const myCustomization: Customization<
34
+ * QueryCtx,
35
+ * { sessionId: VId<"sessions"> },
36
+ * { db: DatabaseReader, user: User, session: Session },
37
+ * {},
38
+ * > = {
39
+ * args: { sessionId: v.id("sessions") },
40
+ * input: async (ctx, args) => {
41
+ * const user = await getUserOrNull(ctx);
42
+ * const session = await db.get(sessionId);
43
+ * const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
44
+ * return { ctx: { db, user, session }, args: {} };
45
+ * },
46
+ * };
47
+ *
48
+ * const myQueryBuilder = customQuery(query, myCustomization);
49
+ * ```
50
+ *
51
+ * If the required args are not returned, they will not be provided for the
52
+ * modified function. All returned ctx and args will show up in the type
53
+ * signature for the modified function. To remove something from `ctx`, you
54
+ * can return it as `undefined`.
55
+
56
+ * The `input` function can also return an `onSuccess` callback that will be
57
+ * called after the function executes successfully. The `onSuccess` callback
58
+ * has access to resources created during input processing via closure.
59
+ */
60
+ type Customization<Ctx extends Record<string, any>, CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, ExtraArgs extends Record<string, any> = Record<string, any>> = {
61
+ args: CustomArgsValidator;
62
+ input: (ctx: Ctx, args: ObjectType<CustomArgsValidator>, extra: ExtraArgs) => Promise<{
63
+ ctx: CustomCtx;
64
+ args: CustomMadeArgs;
65
+ onSuccess?: (obj: {
66
+ ctx: Ctx;
67
+ args: Record<string, unknown>;
68
+ result: unknown;
69
+ }) => void | Promise<void>;
70
+ }> | {
71
+ ctx: CustomCtx;
72
+ args: CustomMadeArgs;
73
+ onSuccess?: (obj: {
74
+ ctx: Ctx;
75
+ args: Record<string, unknown>;
76
+ result: unknown;
77
+ }) => void | Promise<void>;
78
+ };
79
+ };
80
+ /**
81
+ * A Convex function (query, mutation, or action) to be registered for the API.
82
+ * Convenience to specify the registration type based on function type.
83
+ */
84
+ type Registration<FuncType extends 'query' | 'mutation' | 'action', Visibility extends FunctionVisibility, Args extends DefaultFunctionArgs, Output> = {
85
+ query: RegisteredQuery<Visibility, Args, Output>;
86
+ mutation: RegisteredMutation<Visibility, Args, Output>;
87
+ action: RegisteredAction<Visibility, Args, Output>;
88
+ }[FuncType];
89
+ //#endregion
90
+ //#region src/internal/upstream/server/zod4.d.ts
91
+ /**
92
+ * zCustomQuery is like customQuery, but allows validation via zod.
93
+ * You can define custom behavior on top of `query` or `internalQuery`
94
+ * by passing a function that modifies the ctx and args. Or NoOp to do nothing.
95
+ *
96
+ * Example usage:
97
+ * ```ts
98
+ * const myQueryBuilder = zCustomQuery(query, {
99
+ * args: { sessionId: v.id("sessions") },
100
+ * input: async (ctx, args) => {
101
+ * const user = await getUserOrNull(ctx);
102
+ * const session = await db.get(sessionId);
103
+ * const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
104
+ * return { ctx: { db, user, session }, args: {} };
105
+ * },
106
+ * });
107
+ *
108
+ * // Using the custom builder
109
+ * export const getSomeData = myQueryBuilder({
110
+ * args: { someArg: z.string() },
111
+ * handler: async (ctx, args) => {
112
+ * const { db, user, session, scheduler } = ctx;
113
+ * const { someArg } = args;
114
+ * // ...
115
+ * }
116
+ * });
117
+ * ```
118
+ *
119
+ * Simple usage only modifying ctx:
120
+ * ```ts
121
+ * const myInternalQuery = zCustomQuery(
122
+ * internalQuery,
123
+ * customCtx(async (ctx) => {
124
+ * return {
125
+ * // Throws an exception if the user isn't logged in
126
+ * user: await getUserByTokenIdentifier(ctx),
127
+ * };
128
+ * })
129
+ * );
130
+ *
131
+ * // Using it
132
+ * export const getUser = myInternalQuery({
133
+ * args: { email: z.string().email() },
134
+ * handler: async (ctx, args) => {
135
+ * console.log(args.email);
136
+ * return ctx.user;
137
+ * },
138
+ * });
139
+ *
140
+ * @param query The query to be modified. Usually `query` or `internalQuery`
141
+ * from `_generated/server`.
142
+ * @param customization The customization to be applied to the query, changing ctx and args.
143
+ * @returns A new query builder using zod validation to define queries.
144
+ */
145
+ 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> = object>(query: QueryBuilder<DataModel, Visibility>, customization: Customization<GenericQueryCtx<DataModel>, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<"query", CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericQueryCtx<DataModel>, Visibility, ExtraArgs>;
146
+ /**
147
+ * zCustomMutation is like customMutation, but allows validation via zod.
148
+ * You can define custom behavior on top of `mutation` or `internalMutation`
149
+ * by passing a function that modifies the ctx and args. Or NoOp to do nothing.
150
+ *
151
+ * Example usage:
152
+ * ```ts
153
+ * const myMutationBuilder = zCustomMutation(mutation, {
154
+ * args: { sessionId: v.id("sessions") },
155
+ * input: async (ctx, args) => {
156
+ * const user = await getUserOrNull(ctx);
157
+ * const session = await db.get(sessionId);
158
+ * const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
159
+ * return { ctx: { db, user, session }, args: {} };
160
+ * },
161
+ * });
162
+ *
163
+ * // Using the custom builder
164
+ * export const getSomeData = myMutationBuilder({
165
+ * args: { someArg: z.string() },
166
+ * handler: async (ctx, args) => {
167
+ * const { db, user, session, scheduler } = ctx;
168
+ * const { someArg } = args;
169
+ * // ...
170
+ * }
171
+ * });
172
+ * ```
173
+ *
174
+ * Simple usage only modifying ctx:
175
+ * ```ts
176
+ * const myInternalMutation = zCustomMutation(
177
+ * internalMutation,
178
+ * customCtx(async (ctx) => {
179
+ * return {
180
+ * // Throws an exception if the user isn't logged in
181
+ * user: await getUserByTokenIdentifier(ctx),
182
+ * };
183
+ * })
184
+ * );
185
+ *
186
+ * // Using it
187
+ * export const getUser = myInternalMutation({
188
+ * args: { email: z.string().email() },
189
+ * handler: async (ctx, args) => {
190
+ * console.log(args.email);
191
+ * return ctx.user;
192
+ * },
193
+ * });
194
+ *
195
+ * @param mutation The mutation to be modified. Usually `mutation` or `internalMutation`
196
+ * from `_generated/server`.
197
+ * @param customization The customization to be applied to the mutation, changing ctx and args.
198
+ * @returns A new mutation builder using zod validation to define queries.
199
+ */
200
+ declare function zCustomMutation<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record<string, any> = object>(mutation: MutationBuilder<DataModel, Visibility>, customization: Customization<GenericMutationCtx<DataModel>, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<"mutation", CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericMutationCtx<DataModel>, Visibility, ExtraArgs>;
201
+ /**
202
+ * zCustomAction is like customAction, but allows validation via zod.
203
+ * You can define custom behavior on top of `action` or `internalAction`
204
+ * by passing a function that modifies the ctx and args. Or NoOp to do nothing.
205
+ *
206
+ * Example usage:
207
+ * ```ts
208
+ * const myActionBuilder = zCustomAction(action, {
209
+ * args: { sessionId: v.id("sessions") },
210
+ * input: async (ctx, args) => {
211
+ * const user = await getUserOrNull(ctx);
212
+ * const session = await db.get(sessionId);
213
+ * const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
214
+ * return { ctx: { db, user, session }, args: {} };
215
+ * },
216
+ * });
217
+ *
218
+ * // Using the custom builder
219
+ * export const getSomeData = myActionBuilder({
220
+ * args: { someArg: z.string() },
221
+ * handler: async (ctx, args) => {
222
+ * const { db, user, session, scheduler } = ctx;
223
+ * const { someArg } = args;
224
+ * // ...
225
+ * }
226
+ * });
227
+ * ```
228
+ *
229
+ * Simple usage only modifying ctx:
230
+ * ```ts
231
+ * const myInternalAction = zCustomAction(
232
+ * internalAction,
233
+ * customCtx(async (ctx) => {
234
+ * return {
235
+ * // Throws an exception if the user isn't logged in
236
+ * user: await getUserByTokenIdentifier(ctx),
237
+ * };
238
+ * })
239
+ * );
240
+ *
241
+ * // Using it
242
+ * export const getUser = myInternalAction({
243
+ * args: { email: z.string().email() },
244
+ * handler: async (ctx, args) => {
245
+ * console.log(args.email);
246
+ * return ctx.user;
247
+ * },
248
+ * });
249
+ *
250
+ * @param action The action to be modified. Usually `action` or `internalAction`
251
+ * from `_generated/server`.
252
+ * @param customization The customization to be applied to the action, changing ctx and args.
253
+ * @returns A new action builder using zod validation to define queries.
254
+ */
255
+ declare function zCustomAction<CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, Visibility extends FunctionVisibility, DataModel extends GenericDataModel, ExtraArgs extends Record<string, any> = object>(action: ActionBuilder<DataModel, Visibility>, customization: Customization<GenericActionCtx<DataModel>, CustomArgsValidator, CustomCtx, CustomMadeArgs, ExtraArgs>): CustomBuilder<"action", CustomArgsValidator, CustomCtx, CustomMadeArgs, GenericActionCtx<DataModel>, Visibility, ExtraArgs>;
256
+ /**
257
+ * Creates a validator for a Convex `Id`.
258
+ *
259
+ * - When **used within Zod**, it will only check that the ID is a string.
260
+ * - When **converted to a Convex validator** (e.g. through {@link zodToConvex}),
261
+ * it will check that it's for the right table.
262
+ *
263
+ * @param tableName - The table that the `Id` references. i.e. `Id<tableName>`
264
+ * @returns A Zod schema representing a Convex `Id`
265
+ */
266
+ declare const zid: <DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel> = TableNamesInDataModel<DataModel>>(tableName: TableName) => Zid<TableName>;
267
+ /** The type of Convex validators in Zod */
268
+ type Zid<TableName extends string> = z$1.ZodCustom<GenericId<TableName>> & zCore.$ZodRecordKey;
269
+ /**
270
+ * Useful to get the input context type for a custom function using Zod.
271
+ */
272
+ type ZCustomCtx<Builder> = Builder extends CustomBuilder<any, any, infer CustomCtx, any, infer InputCtx, any, any> ? Overwrite<InputCtx, CustomCtx> : never;
273
+ /**
274
+ * Turns a Zod or Zod Mini validator into a Convex validator.
275
+ *
276
+ * The Convex validator will be as close to possible to the Zod validator,
277
+ * but might be broader than the Zod validator:
278
+ *
279
+ * ```ts
280
+ * zodToConvex(z.string().email()) // → v.string()
281
+ * ```
282
+ *
283
+ * This function is useful when running the Zod validator _after_ running the Convex validator
284
+ * (i.e. the Convex validator validates the input of the Zod validator). Hence, the Convex types
285
+ * will match the _input type_ of Zod transformations:
286
+ * ```ts
287
+ * zodToConvex(z.object({
288
+ * name: z.string().default("Nicolas"),
289
+ * })) // → v.object({ name: v.optional(v.string()) })
290
+ *
291
+ * zodToConvex(z.object({
292
+ * name: z.string().transform(s => s.length)
293
+ * })) // → v.object({ name: v.string() })
294
+ * ````
295
+ *
296
+ * This function is useful for:
297
+ * * **Validating function arguments with Zod**: through {@link zCustomQuery},
298
+ * {@link zCustomMutation} and {@link zCustomAction}, you can define the argument validation logic
299
+ * using Zod validators instead of Convex validators. `zodToConvex` will generate a Convex validator
300
+ * from your Zod validator. This will allow you to:
301
+ * - validate at run time that Convex IDs are from the right table (using {@link zid})
302
+ * - allow some features of Convex to understand the expected shape of the arguments
303
+ * (e.g. argument validation/prefilling in the function runner on the Convex dashboard)
304
+ * - still run the full Zod validation when the function runs
305
+ * (which is useful for more advanced Zod validators like `z.string().email()`)
306
+ * * **Validating data after reading it from the database**: if you want to write your DB schema
307
+ * with Zod, you can run Zod whenever you read from the database to check that the data
308
+ * still matches the schema. Note that this approach won’t ensure that the data stored in the DB
309
+ * matches the Zod schema; see
310
+ * https://stack.convex.dev/typescript-zod-function-validation#can-i-use-zod-to-define-my-database-types-too
311
+ * for more details.
312
+ *
313
+ * Note that some values might be valid in Zod but not in Convex,
314
+ * in the same way that valid JavaScript values might not be valid
315
+ * Convex values for the corresponding Convex type.
316
+ * (see the limits of Convex data types on https://docs.convex.dev/database/types).
317
+ *
318
+ * ```
319
+ * ┌─────────────────────────────────────┬─────────────────────────────────────┐
320
+ * │ **zodToConvex** │ zodOutputToConvex │
321
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
322
+ * │ For when the Zod validator runs │ For when the Zod validator runs │
323
+ * │ _after_ the Convex validator │ _before_ the Convex validator │
324
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
325
+ * │ Convex types use the _input types_ │ Convex types use the _return types_ │
326
+ * │ of Zod transformations │ of Zod transformations │
327
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
328
+ * │ The Convex validator can be less │ The Convex validator can be less │
329
+ * │ strict (i.e. some inputs might be │ strict (i.e. the type in Convex can │
330
+ * │ accepted by Convex then rejected │ be less precise than the type in │
331
+ * │ by Zod) │ the Zod output) │
332
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
333
+ * │ When using Zod schemas │ When using Zod schemas │
334
+ * │ for function definitions: │ for function definitions: │
335
+ * │ used for _arguments_ │ used for _return values_ │
336
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
337
+ * │ When validating contents of the │ When validating contents of the │
338
+ * │ database with a Zod schema: │ database with a Zod schema: │
339
+ * │ used to validate data │ used to validate data │
340
+ * │ _after reading_ │ _before writing_ │
341
+ * └─────────────────────────────────────┴─────────────────────────────────────┘
342
+ * ```
343
+ *
344
+ * @param zod Zod validator can be a Zod object, or a Zod type like `z.string()`
345
+ * @returns Convex Validator (e.g. `v.string()` from "convex/values")
346
+ * @throws If there is no equivalent Convex validator for the value (e.g. `z.date()`)
347
+ */
348
+ declare function zodToConvex<Z extends zCore.$ZodType>(validator: Z): ConvexValidatorFromZod<Z, 'required'>;
349
+ /**
350
+ * Converts a Zod or Zod Mini validator to a Convex validator that checks the value _after_
351
+ * it has been validated (and possibly transformed) by the Zod validator.
352
+ *
353
+ * This is similar to {@link zodToConvex}, but is meant for cases where the Convex
354
+ * validator runs _after_ the Zod validator. Thus, the Convex type refers to the
355
+ * _output_ type of the Zod transformations:
356
+ * ```ts
357
+ * zodOutputToConvex(z.object({
358
+ * name: z.string().default("Nicolas"),
359
+ * })) // → v.object({ name: v.string() })
360
+ *
361
+ * zodOutputToConvex(z.object({
362
+ * name: z.string().transform(s => s.length)
363
+ * })) // → v.object({ name: v.number() })
364
+ * ````
365
+ *
366
+ * This function can be useful for:
367
+ * - **Validating function return values with Zod**: through {@link zCustomQuery},
368
+ * {@link zCustomMutation} and {@link zCustomAction}, you can define the `returns` property
369
+ * of a function using Zod validators instead of Convex validators.
370
+ * - **Validating data after reading it from the database**: if you want to write your DB schema
371
+ * Zod validators, you can run Zod whenever you write to the database to ensure your data matches
372
+ * the expected format. Note that this approach won’t ensure that the data stored in the DB
373
+ * isn’t modified manually in a way that doesn’t match your Zod schema; see
374
+ * https://stack.convex.dev/typescript-zod-function-validation#can-i-use-zod-to-define-my-database-types-too
375
+ * for more details.
376
+ *
377
+ * ```
378
+ * ┌─────────────────────────────────────┬─────────────────────────────────────┐
379
+ * │ zodToConvex │ **zodOutputToConvex** │
380
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
381
+ * │ For when the Zod validator runs │ For when the Zod validator runs │
382
+ * │ _after_ the Convex validator │ _before_ the Convex validator │
383
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
384
+ * │ Convex types use the _input types_ │ Convex types use the _return types_ │
385
+ * │ of Zod transformations │ of Zod transformations │
386
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
387
+ * │ The Convex validator can be less │ The Convex validator can be less │
388
+ * │ strict (i.e. some inputs might be │ strict (i.e. the type in Convex can │
389
+ * │ accepted by Convex then rejected │ be less precise than the type in │
390
+ * │ by Zod) │ the Zod output) │
391
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
392
+ * │ When using Zod schemas │ When using Zod schemas │
393
+ * │ for function definitions: │ for function definitions: │
394
+ * │ used for _arguments_ │ used for _return values_ │
395
+ * ├─────────────────────────────────────┼─────────────────────────────────────┤
396
+ * │ When validating contents of the │ When validating contents of the │
397
+ * │ database with a Zod schema: │ database with a Zod schema: │
398
+ * │ used to validate data │ used to validate data │
399
+ * │ _after reading_ │ _before writing_ │
400
+ * └─────────────────────────────────────┴─────────────────────────────────────┘
401
+ * ```
402
+ *
403
+ * @param z The zod validator
404
+ * @returns Convex Validator (e.g. `v.string()` from "convex/values")
405
+ * @throws If there is no equivalent Convex validator for the value (e.g. `z.date()`)
406
+ */
407
+ declare function zodOutputToConvex<Z extends zCore.$ZodType>(validator: Z): ConvexValidatorFromZodOutput<Z, 'required'>;
408
+ type ZodFields = Record<string, zCore.$ZodType>;
409
+ /**
410
+ * Like {@link zodToConvex}, but it takes in a bare object, as expected by Convex
411
+ * function arguments, or the argument to {@link defineTable}.
412
+ *
413
+ * ```ts
414
+ * zodToConvexFields({
415
+ * name: z.string().default("Nicolas"),
416
+ * }) // → { name: v.optional(v.string()) }
417
+ * ```
418
+ *
419
+ * @param fields Object with string keys and Zod validators as values
420
+ * @returns Object with the same keys, but with Convex validators as values
421
+ */
422
+ declare function zodToConvexFields<Fields extends ZodFields>(fields: Fields): { [k in keyof Fields]: Fields[k] extends zCore.$ZodType ? ConvexValidatorFromZod<Fields[k], "required"> : never };
423
+ /**
424
+ * Like {@link zodOutputToConvex}, but it takes in a bare object, as expected by
425
+ * Convex function arguments, or the argument to {@link defineTable}.
426
+ *
427
+ * ```ts
428
+ * zodOutputToConvexFields({
429
+ * name: z.string().default("Nicolas"),
430
+ * }) // → { name: v.string() }
431
+ * ```
432
+ *
433
+ * This is different from {@link zodToConvexFields} because it generates the
434
+ * Convex validator for the output of the Zod validator, not the input;
435
+ * see the documentation of {@link zodToConvex} and {@link zodOutputToConvex}
436
+ * for more details.
437
+ *
438
+ * @param zod Object with string keys and Zod validators as values
439
+ * @returns Object with the same keys, but with Convex validators as values
440
+ */
441
+ declare function zodOutputToConvexFields<Fields extends ZodFields>(fields: Fields): { [k in keyof Fields]: ConvexValidatorFromZodOutput<Fields[k], "required"> };
442
+ /**
443
+ * Turns a Convex validator into a Zod validator.
444
+ *
445
+ * This is useful when you want to use types you defined using Convex validators
446
+ * with external libraries that expect to receive a Zod validator.
447
+ *
448
+ * ```ts
449
+ * convexToZod(v.string()) // → z.string()
450
+ * ```
451
+ *
452
+ * This function returns Zod validators, not Zod Mini validators.
453
+ *
454
+ * @param convexValidator Convex validator can be any validator from "convex/values" e.g. `v.string()`
455
+ * @returns Zod validator (e.g. `z.string()`) with inferred type matching the Convex validator
456
+ */
457
+ declare function convexToZod<V extends GenericValidator>(convexValidator: V): ZodValidatorFromConvex<V>;
458
+ /**
459
+ * Like {@link convexToZod}, but it takes in a bare object, as expected by Convex
460
+ * function arguments, or the argument to {@link defineTable}.
461
+ *
462
+ * ```ts
463
+ * convexToZodFields({
464
+ * name: v.string(),
465
+ * }) // → { name: z.string() }
466
+ * ```
467
+ *
468
+ * @param convexValidators Object with string keys and Convex validators as values
469
+ * @returns Object with the same keys, but with Zod validators as values
470
+ */
471
+ declare function convexToZodFields<C extends PropertyValidators>(convexValidators: C): { [k in keyof C]: ZodValidatorFromConvex<C[k]> };
472
+ /**
473
+ * Zod helper for adding Convex system fields to a record to return.
474
+ *
475
+ * ```ts
476
+ * withSystemFields("users", {
477
+ * name: z.string(),
478
+ * })
479
+ * // → {
480
+ * // name: z.string(),
481
+ * // _id: zid("users"),
482
+ * // _creationTime: z.number(),
483
+ * // }
484
+ * ```
485
+ *
486
+ * @param tableName - The table where records are from, i.e. Doc<tableName>
487
+ * @param zObject - Validators for the user-defined fields on the document.
488
+ * @returns Zod shape for use with `z.object(shape)` that includes system fields.
489
+ */
490
+ declare function withSystemFields<Table extends string, T extends {
491
+ [key: string]: zCore.$ZodType;
492
+ }>(tableName: Table, zObject: T): T & {
493
+ _id: Zid<Table>;
494
+ _creationTime: z$1.ZodNumber;
495
+ };
496
+ /**
497
+ * A builder that customizes a Convex function, whether or not it validates
498
+ * arguments. If the customization requires arguments, however, the resulting
499
+ * builder will require argument validation too.
500
+ */
501
+ type CustomBuilder<FuncType extends 'query' | 'mutation' | 'action', CustomArgsValidator extends PropertyValidators, CustomCtx extends Record<string, any>, CustomMadeArgs extends Record<string, any>, InputCtx, Visibility extends FunctionVisibility, ExtraArgs extends Record<string, any>> = <ArgsValidator extends ZodFields | zCore.$ZodObject<any> | void, ReturnsZodValidator extends zCore.$ZodType | ZodFields | void = void, ReturnValue extends ReturnValueInput<ReturnsZodValidator> = any>(func: ({
502
+ /**
503
+ * Specify the arguments to the function as a Zod validator.
504
+ */
505
+ args?: ArgsValidator;
506
+ handler: (ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<ArgsOutput<ArgsValidator>, CustomMadeArgs>) => ReturnValue;
507
+ /**
508
+ * Validates the value returned by the function.
509
+ * Note: you can't pass an object directly without wrapping it
510
+ * in `z.object()`.
511
+ */
512
+ returns?: ReturnsZodValidator;
513
+ /**
514
+ * If true, the function will not be validated by Convex,
515
+ * in case you're seeing performance issues with validating twice.
516
+ */
517
+ skipConvexValidation?: boolean;
518
+ } & { [key in keyof ExtraArgs as key extends 'args' | 'handler' | 'skipConvexValidation' | 'returns' ? never : key]: ExtraArgs[key] }) | ((ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<ArgsOutput<ArgsValidator>, CustomMadeArgs>) => ReturnValue)) => Registration<FuncType, Visibility, ArgsArrayToObject<CustomArgsValidator extends Record<string, never> ? ArgsInput<ArgsValidator> : ArgsInput<ArgsValidator> extends [infer A] ? [Expand<A & ObjectType<CustomArgsValidator>>] : [ObjectType<CustomArgsValidator>]>, ReturnsZodValidator extends void ? ReturnValue : ReturnValueOutput<ReturnsZodValidator>>;
519
+ type ArgsForHandlerType<OneOrZeroArgs extends [] | [Record<string, any>], CustomMadeArgs extends Record<string, any>> = CustomMadeArgs extends Record<string, never> ? OneOrZeroArgs : OneOrZeroArgs extends [infer A] ? [Expand<A & CustomMadeArgs>] : [CustomMadeArgs];
520
+ type NullToUndefinedOrNull<T> = T extends null ? T | undefined | void : T;
521
+ type Returns<T> = Promise<NullToUndefinedOrNull<T>> | NullToUndefinedOrNull<T>;
522
+ type ReturnValueInput<ReturnsValidator extends zCore.$ZodType | ZodFields | void> = [ReturnsValidator] extends [zCore.$ZodType] ? Returns<zCore.input<ReturnsValidator>> : [ReturnsValidator] extends [ZodFields] ? Returns<zCore.input<zCore.$ZodObject<ReturnsValidator>>> : any;
523
+ type ReturnValueOutput<ReturnsValidator extends zCore.$ZodType | ZodFields | void> = [ReturnsValidator] extends [zCore.$ZodType] ? Returns<zCore.output<ReturnsValidator>> : [ReturnsValidator] extends [ZodFields] ? Returns<zCore.output<zCore.$ZodObject<ReturnsValidator, zCore.$strict>>> : any;
524
+ type ArgsInput<ArgsValidator extends ZodFields | zCore.$ZodObject<any> | void> = [ArgsValidator] extends [zCore.$ZodObject<any>] ? [zCore.input<ArgsValidator>] : ArgsValidator extends Record<string, never> ? [{}] : [ArgsValidator] extends [Record<string, z$1.ZodTypeAny>] ? [zCore.input<zCore.$ZodObject<ArgsValidator, zCore.$strict>>] : OneArgArray;
525
+ type ArgsOutput<ArgsValidator extends ZodFields | zCore.$ZodObject<any> | void> = [ArgsValidator] extends [zCore.$ZodObject<any>] ? [zCore.output<ArgsValidator>] : [ArgsValidator] extends [ZodFields] ? [zCore.output<zCore.$ZodObject<ArgsValidator, zCore.$strict>>] : OneArgArray;
526
+ type Overwrite<T, U> = Omit<T, keyof U> & U;
527
+ type OneArgArray<ArgsObject extends DefaultFunctionArgs = DefaultFunctionArgs> = [ArgsObject];
528
+ /**
529
+ * Return type of {@link zodToConvex}.
530
+ */
531
+ type ConvexValidatorFromZod<Z extends zCore.$ZodType, IsOptional extends 'required' | 'optional'> = IsUnknownOrAny<Z> extends true ? GenericValidator : Z extends zCore.$ZodDefault<infer Inner extends zCore.$ZodType> ? VOptional<ConvexValidatorFromZod<Inner, 'optional'>> : Z extends zCore.$ZodPipe<infer Input extends zCore.$ZodType, infer _Output extends zCore.$ZodType> ? ConvexValidatorFromZod<Input, IsOptional> : ConvexValidatorFromZodCommon<Z, IsOptional>;
532
+ /**
533
+ * Return type of {@link zodOutputToConvex}.
534
+ */
535
+ type ConvexValidatorFromZodOutput<Z extends zCore.$ZodType, IsOptional extends 'required' | 'optional'> = IsUnknownOrAny<Z> extends true ? GenericValidator : Z extends zCore.$ZodDefault<infer Inner extends zCore.$ZodType> ? VRequired<ConvexValidatorFromZodOutput<Inner, 'required'>> : Z extends zCore.$ZodPipe<infer _Input extends zCore.$ZodType, infer Output extends zCore.$ZodType> ? ConvexValidatorFromZodOutput<Output, IsOptional> : Z extends zCore.$ZodOptional<infer Inner extends zCore.$ZodType> ? VOptional<ConvexValidatorFromZodOutput<Inner, 'optional'>> : Z extends zCore.$ZodNullable<infer Inner extends zCore.$ZodType> ? ConvexValidatorFromZodOutput<Inner, IsOptional> extends Validator<any, 'optional', any> ? VUnion<ConvexValidatorFromZodOutput<Inner, IsOptional>['type'] | null | undefined, [VRequired<ConvexValidatorFromZodOutput<Inner, IsOptional>>, VNull], 'optional', ConvexValidatorFromZodOutput<Inner, IsOptional>['fieldPaths']> : VUnion<ConvexValidatorFromZodOutput<Inner, IsOptional>['type'] | null, [VRequired<ConvexValidatorFromZodOutput<Inner, IsOptional>>, VNull], IsOptional, ConvexValidatorFromZodOutput<Inner, IsOptional>['fieldPaths']> : ConvexValidatorFromZodCommon<Z, IsOptional>;
536
+ type ConvexValidatorFromZodCommon<Z extends zCore.$ZodType, IsOptional extends 'required' | 'optional'> = Z extends Zid<infer TableName> ? VId<GenericId<TableName>> : Z extends zCore.$ZodString ? VString<zCore.infer<Z>, IsOptional> : Z extends zCore.$ZodNumber ? VFloat64<zCore.infer<Z>, IsOptional> : Z extends zCore.$ZodNaN ? VFloat64<zCore.infer<Z>, IsOptional> : Z extends zCore.$ZodBigInt ? VInt64<zCore.infer<Z>, IsOptional> : Z extends zCore.$ZodBoolean ? VBoolean<zCore.infer<Z>, IsOptional> : Z extends zCore.$ZodNull ? VNull<zCore.infer<Z>, IsOptional> : Z extends zCore.$ZodUnknown ? VAny<any, 'required'> : Z extends zCore.$ZodAny ? VAny<zCore.infer<Z>, 'required'> : Z extends zCore.$ZodArray<infer Inner extends zCore.$ZodType> ? ConvexValidatorFromZod<Inner, 'required'> extends GenericValidator ? VArray<ConvexValidatorFromZod<Inner, 'required'>['type'][], ConvexValidatorFromZod<Inner, 'required'>, IsOptional> : never : Z extends zCore.$ZodObject<infer Fields extends Readonly<zCore.$ZodShape>> ? VObject<zCore.infer<Z>, ConvexObjectFromZodShape<Fields>, IsOptional> : Z extends zCore.$ZodNever ? VUnion<never, [], IsOptional, never> : Z extends zCore.$ZodUnion<infer T extends readonly zCore.$ZodType[]> ? ConvexUnionValidatorFromZod<T> : Z extends zCore.$ZodTuple<infer Inner extends readonly zCore.$ZodType[], infer Rest extends null | zCore.$ZodType> ? VArray<null extends Rest ? Array<ConvexValidatorFromZod<Inner[number], 'required'>['type']> : Array<ConvexValidatorFromZod<Inner[number], 'required'>['type'] | zCore.infer<Rest>>, null extends Rest ? ConvexUnionValidatorFromZod<Inner> : ConvexUnionValidatorFromZod<[...Inner, Rest extends zCore.$ZodType ? Rest : never]>, IsOptional> : Z extends zCore.$ZodLiteral<infer Literal extends zCore.util.Literal> ? ConvexLiteralFromZod<Literal, IsOptional> : Z extends zCore.$ZodEnum<infer EnumContents extends zCore.util.EnumLike> ? VUnion<zCore.infer<Z>, keyof EnumContents extends string ? { [K in keyof EnumContents]: VLiteral<EnumContents[K], 'required'> }[keyof EnumContents][] : never, IsOptional> : Z extends zCore.$ZodOptional<infer Inner extends zCore.$ZodType> ? VOptional<ConvexValidatorFromZod<Inner, 'optional'>> : Z extends zCore.$ZodNonOptional<infer Inner extends zCore.$ZodType> ? VRequired<ConvexValidatorFromZod<Inner, 'required'>> : Z extends zCore.$ZodNullable<infer Inner extends zCore.$ZodType> ? ConvexValidatorFromZod<Inner, IsOptional> extends Validator<any, 'optional', any> ? VUnion<ConvexValidatorFromZod<Inner, IsOptional>['type'] | null | undefined, [VRequired<ConvexValidatorFromZod<Inner, IsOptional>>, VNull], 'optional', ConvexValidatorFromZod<Inner, IsOptional>['fieldPaths']> : VUnion<ConvexValidatorFromZod<Inner, IsOptional>['type'] | null, [VRequired<ConvexValidatorFromZod<Inner, IsOptional>>, VNull], IsOptional, ConvexValidatorFromZod<Inner, IsOptional>['fieldPaths']> : Z extends zCore.$ZodBranded<infer Inner extends zCore.$ZodType, infer Brand> ? Inner extends zCore.$ZodString ? VString<string & zCore.$brand<Brand>, IsOptional> : Inner extends zCore.$ZodNumber ? VFloat64<number & zCore.$brand<Brand>, IsOptional> : Inner extends zCore.$ZodBigInt ? VInt64<bigint & zCore.$brand<Brand>, IsOptional> : Inner extends zCore.$ZodObject<infer Fields extends Readonly<zCore.$ZodShape>> ? VObject<zCore.infer<Inner> & zCore.$brand<Brand>, ConvexObjectFromZodShape<Fields>, IsOptional> : ConvexValidatorFromZod<Inner, IsOptional> : Z extends zCore.$ZodRecord<infer Key extends zCore.$ZodRecordKey, infer Value extends zCore.$ZodType> ? ConvexValidatorFromZodRecord<Key, Value, IsOptional> : Z extends zCore.$ZodReadonly<infer Inner extends zCore.$ZodType> ? ConvexValidatorFromZod<Inner, IsOptional> : Z extends zCore.$ZodLazy<infer Inner extends zCore.$ZodType> ? ConvexValidatorFromZod<Inner, IsOptional> : Z extends zCore.$ZodTemplateLiteral<infer Template extends string> ? VString<Template, IsOptional> : Z extends zCore.$ZodCatch<infer T extends zCore.$ZodType> ? ConvexValidatorFromZod<T, IsOptional> : Z extends zCore.$ZodTransform<any, any> ? VAny<any, 'required'> : Z extends zCore.$ZodCustom<any> ? VAny<any, 'required'> : Z extends zCore.$ZodIntersection<any> ? VAny<any, 'required'> : IsConvexUnencodableType<Z> extends true ? never : GenericValidator;
537
+ type ConvexUnionValidatorFromZod<T extends readonly zCore.$ZodType[]> = VUnion<ConvexValidatorFromZod<T[number], 'required'>['type'], T extends readonly [infer Head extends zCore.$ZodType, ...infer Tail extends zCore.$ZodType[]] ? [VRequired<ConvexValidatorFromZod<Head, 'required'>>, ...ConvexUnionValidatorFromZodMembers<Tail>] : T extends readonly [] ? [] : Validator<any, 'required', any>[], 'required', ConvexValidatorFromZod<T[number], 'required'>['fieldPaths']>;
538
+ type ConvexUnionValidatorFromZodMembers<T extends readonly zCore.$ZodType[]> = T extends readonly [infer Head extends zCore.$ZodType, ...infer Tail extends zCore.$ZodType[]] ? [VRequired<ConvexValidatorFromZod<Head, 'required'>>, ...ConvexUnionValidatorFromZodMembers<Tail>] : T extends readonly [] ? [] : Validator<any, 'required', any>[];
539
+ type ConvexObjectFromZodShape<Fields extends Readonly<zCore.$ZodShape>> = Fields extends infer F ? { [K in keyof F]: F[K] extends zCore.$ZodType ? ConvexValidatorFromZod<F[K], 'required'> : Validator<any, 'required', any> } : never;
540
+ type ConvexObjectValidatorFromRecord<Key extends string, Value extends zCore.$ZodType, IsOptional extends 'required' | 'optional', IsPartial extends 'partial' | 'full'> = VObject<IsPartial extends 'partial' ? { [K in Key]?: zCore.infer<Value> } : MakeUndefinedPropertiesOptional<{ [K in Key]: zCore.infer<Value> }>, IsPartial extends 'partial' ? { [K in Key]: VOptional<ConvexValidatorFromZod<Value, 'required'>> } : { [K in Key]: ConvexValidatorFromZod<Value, 'required'> }, IsOptional>;
541
+ type MakeUndefinedPropertiesOptional<Obj extends object> = Expand<{ [K in keyof Obj as undefined extends Obj[K] ? never : K]: Obj[K] } & { [K in keyof Obj as undefined extends Obj[K] ? K : never]?: Obj[K] }>;
542
+ type ConvexValidatorFromZodRecord<Key extends zCore.$ZodRecordKey, Value extends zCore.$ZodType, IsOptional extends 'required' | 'optional'> = Key extends zCore.$ZodString | Zid<any> | zCore.$ZodUnion<infer _Ids extends readonly Zid<any>[]> ? VRecord<Record<zCore.infer<Key>, NotUndefined<zCore.infer<Value>>>, VRequired<ConvexValidatorFromZod<Key, 'required'>>, VRequired<ConvexValidatorFromZod<Value, 'required'>>, IsOptional> : Key extends zCore.$ZodLiteral<infer Literal extends string> ? ConvexObjectValidatorFromRecord<Literal, Value, IsOptional, Key extends zCore.$partial ? 'partial' : 'full'> : Key extends zCore.$ZodUnion<infer Literals extends readonly zCore.$ZodLiteral[]> ? ConvexObjectValidatorFromRecord<zCore.infer<Literals[number]> extends string ? zCore.infer<Literals[number]> : never, Value, IsOptional, Key extends zCore.$partial ? 'partial' : 'full'> : VRecord<Record<string, NotUndefined<zCore.infer<Value>>>, VString<string, 'required'>, VRequired<ConvexValidatorFromZod<Value, 'required'>>, IsOptional>;
543
+ type IsConvexUnencodableType<Z extends zCore.$ZodType> = Z extends zCore.$ZodDate | zCore.$ZodSymbol | zCore.$ZodMap | zCore.$ZodSet | zCore.$ZodPromise | zCore.$ZodFile | zCore.$ZodFunction | zCore.$ZodUndefined | zCore.$ZodVoid ? true : false;
544
+ type IsUnion<T, U extends T = T> = T extends unknown ? [U] extends [T] ? false : true : false;
545
+ type ConvexLiteralFromZod<Literal extends zCore.util.Literal, IsOptional extends 'required' | 'optional'> = undefined extends Literal ? never : [Literal] extends [null] ? VNull<null, IsOptional> : IsUnion<Literal> extends true ? VUnion<Literal, Array<Literal extends unknown ? ConvexLiteralFromZod<Literal, 'required'> : never>, IsOptional, never> : VLiteral<Literal, IsOptional>;
546
+ type IsUnknownOrAny<T> = 0 extends 1 & T ? true : unknown extends T ? true : false;
547
+ /**
548
+ * Better type conversion from a Convex validator to a Zod validator
549
+ * where the output is not a generic ZodType but it's more specific.
550
+ *
551
+ * This allows you to use methods specific to the Zod type (e.g. `.email()` for `z.ZodString`).
552
+ *
553
+ * ```ts
554
+ * ZodValidatorFromConvex<typeof v.string()> // → z.ZodString
555
+ * ```
556
+ */
557
+ type ZodValidatorFromConvex<V extends GenericValidator> = V extends Validator<any, 'optional', any> ? z$1.ZodOptional<ZodFromValidatorBase<VRequired<V>>> : ZodFromValidatorBase<V>;
558
+ type ZodFromValidatorBase<V extends GenericValidator> = V extends VId<infer Type> ? Zid<TableNameFromType<NotUndefined<Type>>> : V extends VString<infer T> ? BrandIfBranded<T, z$1.ZodString> : V extends VFloat64<infer T> ? BrandIfBranded<T, z$1.ZodNumber> : V extends VInt64<any> ? z$1.ZodBigInt : V extends VBoolean<any> ? z$1.ZodBoolean : V extends VNull<any> ? z$1.ZodNull : V extends VArray<any, infer Element> ? Element extends VArray<any, any> ? z$1.ZodArray<zCore.SomeType> : z$1.ZodArray<ZodFromValidatorBase<Element>> : V extends VObject<any, infer Fields extends Record<string, GenericValidator>> ? z$1.ZodObject<ZodShapeFromConvexObject<Fields>, zCore.$strict> : V extends VBytes<any, any> ? never : V extends VLiteral<infer T extends zCore.util.Literal, OptionalProperty> ? z$1.ZodLiteral<NotUndefined<T>> : V extends VRecord<any, infer Key, infer Value, OptionalProperty, any> ? z$1.ZodRecord<ZodFromStringValidator<Key>, ZodFromValidatorBase<Value>> : V extends VUnion<any, [], OptionalProperty, any> ? z$1.ZodNever : V extends VUnion<any, [infer I extends GenericValidator], OptionalProperty, any> ? ZodValidatorFromConvex<I> : V extends VUnion<any, [infer A extends GenericValidator, ...infer Rest extends GenericValidator[]], OptionalProperty, any> ? z$1.ZodUnion<readonly [ZodValidatorFromConvex<A>, ...{ [K in keyof Rest]: ZodValidatorFromConvex<Rest[K]> }]> : V extends VAny<any, OptionalProperty, any> ? z$1.ZodAny : never;
559
+ type BrandIfBranded<InnerType, Validator extends zCore.SomeType> = InnerType extends zCore.$brand<infer Brand> ? zCore.$ZodBranded<Validator, Brand> : Validator;
560
+ type StringValidator = Validator<string, 'required', any>;
561
+ type ZodFromStringValidator<V extends StringValidator> = V extends VId<GenericId<infer TableName extends string>> ? Zid<TableName> : V extends VString<infer T, any> ? BrandIfBranded<T, z$1.ZodString> : V extends VLiteral<infer Literal extends string> ? z$1.ZodLiteral<Literal> : V extends VUnion<any, [], any, any> ? z$1.ZodNever : V extends VUnion<any, [infer I extends GenericValidator], any, any> ? ZodFromStringValidator<I> : V extends VUnion<any, [infer A extends GenericValidator, ...infer Rest extends GenericValidator[]], any, any> ? z$1.ZodUnion<readonly [ZodFromStringValidator<A>, ...{ [K in keyof Rest]: ZodFromStringValidator<Rest[K]> }]> : never;
562
+ type ZodShapeFromConvexObject<Fields extends Record<string, GenericValidator>> = Fields extends infer F ? { [K in keyof F]: F[K] extends GenericValidator ? ZodValidatorFromConvex<F[K]> : never } : never;
563
+ type NotUndefined<T> = Exclude<T, undefined>;
564
+ type TableNameFromType<T> = T extends GenericId<infer TableName> ? TableName : string;
565
+ //#endregion
566
+ //#region src/server/http-builder.d.ts
567
+ declare function extractPathParams(path: string): string[];
568
+ declare function matchPathParams(template: string, pathname: string): Record<string, string> | null;
569
+ declare function handleHttpError(error: unknown): Response;
570
+ /**
571
+ * HttpProcedureBuilder - Fluent builder for HTTP endpoints
572
+ *
573
+ * Uses tRPC-style interface + factory pattern for proper generic type preservation:
574
+ * - Interface declares full generics with explicit return types
575
+ * - Factory function creates implementation objects
576
+ * - This preserves literal types like 'GET' through method chains
577
+ */
578
+ interface HttpProcedureBuilder<TInitialCtx, TCtx, TInput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TParams extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TQuery extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends ProcedureMeta = ProcedureMeta, TMethod extends HttpMethod = HttpMethod, TForm extends UnsetMarker | z.ZodTypeAny = UnsetMarker> {
579
+ _def: HttpProcedureBuilderDef<TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
580
+ /** DELETE endpoint (Hono-style) */
581
+ delete(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'DELETE', TForm>;
582
+ /** Define form data schema (for multipart/form-data uploads) */
583
+ form<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TSchema>;
584
+ /** GET endpoint (Hono-style) */
585
+ get(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'GET', TForm>;
586
+ /** Define request body schema (for POST/PUT/PATCH) */
587
+ input<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TSchema, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
588
+ /** Set procedure metadata (shallow merged when chained) */
589
+ meta(value: TMeta): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
590
+ /**
591
+ * Define the handler for POST/PUT/PATCH/DELETE endpoints (maps to useMutation on client).
592
+ * Handler receives Hono Context `c` for Response helpers (c.json, c.body, c.text).
593
+ * Return Response for custom responses, or plain object for auto JSON serialization.
594
+ */
595
+ mutation<TResult>(handler: (opts: HttpHandlerOpts<TCtx, TInput, TParams, TQuery, TForm>) => Promise<Response | (TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult)>): HttpProcedure<TInput, TOutput, TParams, TQuery, TMethod, TForm>;
596
+ /** Define response schema */
597
+ output<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TSchema, TParams, TQuery, TMeta, TMethod, TForm>;
598
+ /** Define path parameter schema (for :param in path) */
599
+ params<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TSchema, TQuery, TMeta, TMethod, TForm>;
600
+ /** PATCH endpoint (Hono-style) */
601
+ patch(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PATCH', TForm>;
602
+ /** POST endpoint (Hono-style) */
603
+ post(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'POST', TForm>;
604
+ /** PUT endpoint (Hono-style) */
605
+ put(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PUT', TForm>;
606
+ /**
607
+ * Define the handler for GET endpoints (maps to useQuery on client).
608
+ * Handler receives Hono Context `c` for Response helpers (c.json, c.body, c.text).
609
+ * Return Response for custom responses, or plain object for auto JSON serialization.
610
+ */
611
+ query<TResult>(handler: (opts: HttpHandlerOpts<TCtx, TInput, TParams, TQuery, TForm>) => Promise<Response | (TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult)>): HttpProcedure<TInput, TOutput, TParams, TQuery, TMethod, TForm>;
612
+ /** Define the route path and HTTP method */
613
+ route<M extends HttpMethod>(path: string, method: M): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, M, TForm>;
614
+ /** Define query parameter schema (?key=value) */
615
+ searchParams<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TSchema, TMeta, TMethod, TForm>;
616
+ /** Add middleware to the procedure */
617
+ use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<TCtx, TMeta, UnsetMarker, $ContextOverridesOut, unknown> | MiddlewareBuilder<any, // Allow reusable middleware with any context
618
+ TMeta, $ContextOverridesOut, unknown>): HttpProcedureBuilder<TInitialCtx, Overwrite$1<TCtx, $ContextOverridesOut>, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
619
+ }
620
+ /**
621
+ * Create initial HttpProcedureBuilder
622
+ */
623
+ declare function createHttpProcedureBuilder<TCtx, TMeta extends ProcedureMeta>(config: {
624
+ base: HttpProcedureBuilderDef<TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod, UnsetMarker>['functionConfig']['base'];
625
+ createContext: (ctx: GenericActionCtx<GenericDataModel>) => TCtx;
626
+ meta: TMeta;
627
+ transformer?: DataTransformerOptions;
628
+ }): HttpProcedureBuilder<TCtx, TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod, UnsetMarker>;
629
+ //#endregion
630
+ //#region src/server/builder.d.ts
631
+ /**
632
+ * Paginated schema for type inference ONLY.
633
+ * After .paginated() applies defaults, cursor and limit are always defined.
634
+ * The actual runtime schema uses .default() and .transform() for validation.
635
+ */
636
+ declare const paginatedSchemaForTypes: z.ZodObject<{
637
+ cursor: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
638
+ limit: z.ZodNumber;
639
+ }, z.core.$strip>;
640
+ /** Paginated schema type - both cursor and limit are required after .paginated() */
641
+ type PaginatedInputSchema = typeof paginatedSchemaForTypes;
642
+ /** Paginated schema type for external callers - both fields are optional due defaults. */
643
+ declare const paginatedSchemaForClientTypes: z.ZodObject<{
644
+ cursor: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
645
+ limit: z.ZodOptional<z.ZodNumber>;
646
+ }, z.core.$strip>;
647
+ type PaginatedClientInputSchema = typeof paginatedSchemaForClientTypes;
648
+ /**
649
+ * Infer input type from ZodObject schema (for handlers)
650
+ */
651
+ type InferInput<T> = T extends UnsetMarker ? Record<string, never> : T extends z.ZodObject<any> ? z.infer<T> : never;
652
+ /**
653
+ * Infer raw client input before defaults/transforms.
654
+ * Used for generated API arg typing.
655
+ */
656
+ type InferClientInput<T> = T extends UnsetMarker ? Record<string, never> : T extends z.ZodObject<any> ? z.input<T> : never;
657
+ /**
658
+ * Infer input type for middleware (returns unknown for UnsetMarker, matching tRPC)
659
+ * Middleware before .input() receives unknown input
660
+ */
661
+ type InferMiddlewareInput<T> = T extends UnsetMarker ? unknown : T extends z.ZodObject<any> ? z.infer<T> : unknown;
662
+ /**
663
+ * Static-only type hint attached to cRPC exports.
664
+ *
665
+ * Convex validators can widen unsupported types (like Date) to `any`.
666
+ * Codegen can read this hint from `typeof import(...).fn` to recover precise
667
+ * TypeScript input/output types for generated client API refs.
668
+ */
669
+ type CRPCFunctionTypeHint<TArgs, TReturns> = {
670
+ readonly __kitcnTypeHint?: {
671
+ readonly args: TArgs;
672
+ readonly returns: TReturns;
673
+ };
674
+ };
675
+ /** Base config shape for function builders */
676
+ type FunctionBuilderConfig = {
677
+ /** Base function builder (query, mutation, or action from Convex) */base: unknown; /** Internal function builder (internalQuery, etc.) */
678
+ internal?: unknown;
679
+ };
680
+ /** Internal config combining context creator with function builders */
681
+ type InternalFunctionConfig = FunctionBuilderConfig & {
682
+ /** Transform raw Convex context to the base context for procedures */createContext: (ctx: any) => unknown; /** Wire transformer for request/response serialization. */
683
+ transformer: ReturnType<typeof getTransformer>;
684
+ };
685
+ /** Context creators for each function type - all optional, defaults to passthrough */
686
+ type ContextConfig<DataModel extends GenericDataModel> = {
687
+ query?: (ctx: GenericQueryCtx<DataModel>) => unknown;
688
+ mutation?: (ctx: GenericMutationCtx<DataModel>) => unknown;
689
+ action?: (ctx: GenericActionCtx<DataModel>) => unknown;
690
+ };
691
+ /** Infer context types from config - defaults to raw Convex ctx when not specified */
692
+ type InferQueryCtx<T, DataModel extends GenericDataModel> = T extends {
693
+ query: (...args: never[]) => infer R;
694
+ } ? R : GenericQueryCtx<DataModel>;
695
+ type InferMutationCtx<T, DataModel extends GenericDataModel> = T extends {
696
+ mutation: (...args: never[]) => infer R;
697
+ } ? R : GenericMutationCtx<DataModel>;
698
+ type InferActionCtx<T, DataModel extends GenericDataModel> = T extends {
699
+ action: (...args: never[]) => infer R;
700
+ } ? R : GenericActionCtx<DataModel>;
701
+ /** Function builders for each function type */
702
+ type FunctionsConfig = {
703
+ query?: unknown;
704
+ internalQuery?: unknown;
705
+ mutation?: unknown;
706
+ internalMutation?: unknown;
707
+ action?: unknown;
708
+ internalAction?: unknown;
709
+ httpAction?: unknown;
710
+ };
711
+ /** Config for create() including optional defaultMeta */
712
+ type CreateConfig<TMeta extends object> = FunctionsConfig & {
713
+ defaultMeta?: TMeta; /** Optional cRPC payload transformer (always composed with built-in Date support). */
714
+ transformer?: DataTransformerOptions;
715
+ };
716
+ /**
717
+ * Create a middleware factory for building reusable middleware chains
718
+ *
719
+ * @example
720
+ * ```typescript
721
+ * const loggedIn = c.middleware(({ ctx, next }) => {
722
+ * if (!ctx.userId) throw new CRPCError({ code: 'UNAUTHORIZED' });
723
+ * return next({ ctx });
724
+ * });
725
+ *
726
+ * const isAdmin = loggedIn.pipe(({ ctx, next }) => {
727
+ * if (!ctx.user.isAdmin) throw new CRPCError({ code: 'FORBIDDEN' });
728
+ * return next({ ctx });
729
+ * });
730
+ * ```
731
+ */
732
+ declare function createMiddlewareFactory<TDefaultContext, TMeta = object>(): <TContext = TDefaultContext, $ContextOverridesOut = object>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverridesOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverridesOut, unknown>;
733
+ /** Internal definition storing procedure state */
734
+ type ProcedureBuilderDef<TMeta = object> = {
735
+ middlewares: AnyMiddleware[];
736
+ inputSchemas: Record<string, any>[];
737
+ outputSchema?: z.ZodTypeAny;
738
+ meta?: TMeta;
739
+ functionConfig: InternalFunctionConfig; /** Whether this procedure uses internal function (not exposed to clients) */
740
+ isInternal?: boolean;
741
+ };
742
+ /**
743
+ * Fluent procedure builder with full type inference
744
+ *
745
+ * @typeParam TBaseCtx - Base context type from config
746
+ * @typeParam TContext - Current context type (starts as TBaseCtx)
747
+ * @typeParam TContextOverrides - Accumulated context from middleware (starts as UnsetMarker)
748
+ * @typeParam TInput - Input schema (starts as UnsetMarker)
749
+ * @typeParam TOutput - Output schema (starts as UnsetMarker)
750
+ * @typeParam TMeta - Procedure metadata type
751
+ */
752
+ declare class ProcedureBuilder<TBaseCtx, _TContext, TContextOverrides extends UnsetMarker | object = UnsetMarker, TInput extends UnsetMarker | z.ZodObject<any> = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends object = object> {
753
+ protected readonly _def: ProcedureBuilderDef<TMeta>;
754
+ constructor(def: ProcedureBuilderDef<TMeta>);
755
+ /** Add middleware that transforms the context - to be overridden by subclasses */
756
+ protected _use<$ContextOverridesOut>(middlewareOrBuilder: MiddlewareFunction<TBaseCtx, TMeta, TContextOverrides, $ContextOverridesOut> | MiddlewareBuilder<TBaseCtx, TMeta, $ContextOverridesOut>): ProcedureBuilderDef<TMeta>;
757
+ /** Define input schema (chainable - schemas are merged) - to be overridden by subclasses */
758
+ protected _input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): ProcedureBuilderDef<TMeta>;
759
+ /** Define output schema - to be overridden by subclasses */
760
+ protected _output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): ProcedureBuilderDef<TMeta>;
761
+ /** Set procedure metadata (shallow merged when chained) - to be overridden by subclasses */
762
+ protected _meta(value: TMeta): ProcedureBuilderDef<TMeta>;
763
+ /** Merge all input schemas into one */
764
+ protected _getMergedInput(): Record<string, any> | undefined;
765
+ protected _createFunction(handler: any, baseFunction: any, customFn: typeof zCustomQuery | typeof zCustomMutation | typeof zCustomAction, fnType: 'query' | 'mutation' | 'action'): convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
766
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
767
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
768
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
769
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
770
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
771
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T ? T extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
772
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
773
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T extends Record<string, never> ? [{}] : [T] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_1 ? T_1 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_1 extends void ? Promise<any> : [T_1] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_1> extends infer T_2 ? T_2 extends z.core.output<T_1> ? T_2 extends null ? void | T_2 | undefined : T_2 : never : never> | (z.core.output<T_1> extends infer T_3 ? T_3 extends z.core.output<T_1> ? T_3 extends null ? void | T_3 | undefined : T_3 : never : never) : [T_1] extends [{
774
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
775
+ }] ? Promise<z.core.$InferObjectOutput<T_1, {}> extends infer T_4 ? T_4 extends z.core.$InferObjectOutput<T_1, {}> ? T_4 extends null ? void | T_4 | undefined : T_4 : never : never> | (z.core.$InferObjectOutput<T_1, {}> extends infer T_5 ? T_5 extends z.core.$InferObjectOutput<T_1, {}> ? T_5 extends null ? void | T_5 | undefined : T_5 : never : never) : any : never : never> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
776
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
777
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
778
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
779
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
780
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
781
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_6 ? T_6 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
782
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
783
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_6 extends Record<string, never> ? [{}] : [T_6] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_6, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_7 ? T_7 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_7 extends void ? Promise<any> : [T_7] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_7> extends infer T_8 ? T_8 extends z.core.output<T_7> ? T_8 extends null ? void | T_8 | undefined : T_8 : never : never> | (z.core.output<T_7> extends infer T_9 ? T_9 extends z.core.output<T_7> ? T_9 extends null ? void | T_9 | undefined : T_9 : never : never) : [T_7] extends [{
784
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
785
+ }] ? Promise<z.core.$InferObjectOutput<T_7, {}> extends infer T_10 ? T_10 extends z.core.$InferObjectOutput<T_7, {}> ? T_10 extends null ? void | T_10 | undefined : T_10 : never : never> | (z.core.$InferObjectOutput<T_7, {}> extends infer T_11 ? T_11 extends z.core.$InferObjectOutput<T_7, {}> ? T_11 extends null ? void | T_11 | undefined : T_11 : never : never) : any : never : never> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
786
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
787
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
788
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
789
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
790
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
791
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_12 ? T_12 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
792
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
793
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_12 extends Record<string, never> ? [{}] : [T_12] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_12, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_13 ? T_13 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_13 extends void ? Promise<any> : [T_13] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_13> extends infer T_14 ? T_14 extends z.core.output<T_13> ? T_14 extends null ? void | T_14 | undefined : T_14 : never : never> | (z.core.output<T_13> extends infer T_15 ? T_15 extends z.core.output<T_13> ? T_15 extends null ? void | T_15 | undefined : T_15 : never : never) : [T_13] extends [{
794
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
795
+ }] ? Promise<z.core.$InferObjectOutput<T_13, {}> extends infer T_16 ? T_16 extends z.core.$InferObjectOutput<T_13, {}> ? T_16 extends null ? void | T_16 | undefined : T_16 : never : never> | (z.core.$InferObjectOutput<T_13, {}> extends infer T_17 ? T_17 extends z.core.$InferObjectOutput<T_13, {}> ? T_17 extends null ? void | T_17 | undefined : T_17 : never : never) : any : never : never>;
796
+ }
797
+ /**
798
+ * Query-specific procedure builder
799
+ * Only exposes .query() and .internalQuery() methods
800
+ */
801
+ declare class QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends UnsetMarker | object = UnsetMarker, TInput extends UnsetMarker | z.ZodObject<any> = UnsetMarker, TClientInput extends UnsetMarker | z.ZodObject<any> = TInput, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends object = object> extends ProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta> {
802
+ /**
803
+ * Add middleware that transforms the context
804
+ * Middleware receives typed input if called after .input(), unknown otherwise
805
+ * $ContextOverridesOut is inferred from next()
806
+ */
807
+ use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite$1<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<any, // Allow reusable middleware with any context
808
+ TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): QueryProcedureBuilder<TBaseCtx, TContext, Overwrite$1<TContextOverrides, $ContextOverridesOut>, TInput, TClientInput, TOutput, TMeta>;
809
+ /** Set procedure metadata (shallow merged when chained) */
810
+ meta(value: TMeta): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TOutput, TMeta>;
811
+ /** Define input schema (chainable - schemas are merged) */
812
+ input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, TNewInput>, IntersectIfDefined<TClientInput, TNewInput>, TOutput, TMeta>;
813
+ /**
814
+ * Add pagination input (chainable before .query())
815
+ *
816
+ * Creates flat { cursor, limit } input like tRPC and auto-wraps output.
817
+ * User accesses args.cursor and args.limit directly.
818
+ *
819
+ * @param opts.limit - Default/max items per page
820
+ * @param opts.item - Zod schema for each item in the page array
821
+ */
822
+ paginated<TItem extends z.ZodTypeAny>(opts: {
823
+ limit: number;
824
+ item: TItem;
825
+ }): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, PaginatedInputSchema>, IntersectIfDefined<TClientInput, PaginatedClientInputSchema>, z.ZodObject<{
826
+ continueCursor: z.ZodUnion<[z.ZodString, z.ZodNull]>;
827
+ isDone: z.ZodBoolean;
828
+ page: z.ZodArray<TItem>;
829
+ }>, TMeta>;
830
+ /** Define output schema */
831
+ output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TNewOutput, TMeta>;
832
+ /** Create a query */
833
+ query<TResult>(handler: (opts: {
834
+ ctx: Overwrite$1<TContext, TContextOverrides>;
835
+ input: InferInput<TInput>;
836
+ }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): (convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
837
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
838
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
839
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
840
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
841
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
842
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T ? T extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
843
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
844
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T extends Record<string, never> ? [{}] : [T] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_1 ? T_1 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_1 extends void ? Promise<any> : [T_1] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_1> extends infer T_2 ? T_2 extends z.core.output<T_1> ? T_2 extends null ? void | T_2 | undefined : T_2 : never : never> | (z.core.output<T_1> extends infer T_3 ? T_3 extends z.core.output<T_1> ? T_3 extends null ? void | T_3 | undefined : T_3 : never : never) : [T_1] extends [{
845
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
846
+ }] ? Promise<z.core.$InferObjectOutput<T_1, {}> extends infer T_4 ? T_4 extends z.core.$InferObjectOutput<T_1, {}> ? T_4 extends null ? void | T_4 | undefined : T_4 : never : never> | (z.core.$InferObjectOutput<T_1, {}> extends infer T_5 ? T_5 extends z.core.$InferObjectOutput<T_1, {}> ? T_5 extends null ? void | T_5 | undefined : T_5 : never : never) : any : never : never> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
847
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
848
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
849
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
850
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
851
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
852
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_6 ? T_6 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
853
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
854
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_6 extends Record<string, never> ? [{}] : [T_6] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_6, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_7 ? T_7 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_7 extends void ? Promise<any> : [T_7] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_7> extends infer T_8 ? T_8 extends z.core.output<T_7> ? T_8 extends null ? void | T_8 | undefined : T_8 : never : never> | (z.core.output<T_7> extends infer T_9 ? T_9 extends z.core.output<T_7> ? T_9 extends null ? void | T_9 | undefined : T_9 : never : never) : [T_7] extends [{
855
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
856
+ }] ? Promise<z.core.$InferObjectOutput<T_7, {}> extends infer T_10 ? T_10 extends z.core.$InferObjectOutput<T_7, {}> ? T_10 extends null ? void | T_10 | undefined : T_10 : never : never> | (z.core.$InferObjectOutput<T_7, {}> extends infer T_11 ? T_11 extends z.core.$InferObjectOutput<T_7, {}> ? T_11 extends null ? void | T_11 | undefined : T_11 : never : never) : any : never : never> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
857
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
858
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
859
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
860
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
861
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
862
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_12 ? T_12 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
863
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
864
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_12 extends Record<string, never> ? [{}] : [T_12] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_12, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_13 ? T_13 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_13 extends void ? Promise<any> : [T_13] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_13> extends infer T_14 ? T_14 extends z.core.output<T_13> ? T_14 extends null ? void | T_14 | undefined : T_14 : never : never> | (z.core.output<T_13> extends infer T_15 ? T_15 extends z.core.output<T_13> ? T_15 extends null ? void | T_15 | undefined : T_15 : never : never) : [T_13] extends [{
865
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
866
+ }] ? Promise<z.core.$InferObjectOutput<T_13, {}> extends infer T_16 ? T_16 extends z.core.$InferObjectOutput<T_13, {}> ? T_16 extends null ? void | T_16 | undefined : T_16 : never : never> | (z.core.$InferObjectOutput<T_13, {}> extends infer T_17 ? T_17 extends z.core.$InferObjectOutput<T_13, {}> ? T_17 extends null ? void | T_17 | undefined : T_17 : never : never) : any : never : never>) & CRPCFunctionTypeHint<InferClientInput<TClientInput>, TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>;
867
+ /** Mark as internal - returns chainable builder using internal function */
868
+ internal(): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TOutput, TMeta>;
869
+ }
870
+ /**
871
+ * Mutation-specific procedure builder
872
+ * Only exposes .mutation() and .internalMutation() methods
873
+ */
874
+ declare class MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends UnsetMarker | object = UnsetMarker, TInput extends UnsetMarker | z.ZodObject<any> = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends object = object> extends ProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta> {
875
+ /**
876
+ * Add middleware that transforms the context
877
+ * Middleware receives typed input if called after .input(), unknown otherwise
878
+ * $ContextOverridesOut is inferred from next()
879
+ */
880
+ use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite$1<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<any, // Allow reusable middleware with any context
881
+ TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): MutationProcedureBuilder<TBaseCtx, TContext, Overwrite$1<TContextOverrides, $ContextOverridesOut>, TInput, TOutput, TMeta>;
882
+ /** Set procedure metadata (shallow merged when chained) */
883
+ meta(value: TMeta): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
884
+ /** Define input schema (chainable - schemas are merged) */
885
+ input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, TNewInput>, TOutput, TMeta>;
886
+ /** Define output schema */
887
+ output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TNewOutput, TMeta>;
888
+ /** Create a mutation */
889
+ mutation<TResult>(handler: (opts: {
890
+ ctx: Overwrite$1<TContext, TContextOverrides>;
891
+ input: InferInput<TInput>;
892
+ }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): (convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
893
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
894
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
895
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
896
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
897
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
898
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T ? T extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
899
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
900
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T extends Record<string, never> ? [{}] : [T] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_1 ? T_1 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_1 extends void ? Promise<any> : [T_1] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_1> extends infer T_2 ? T_2 extends z.core.output<T_1> ? T_2 extends null ? void | T_2 | undefined : T_2 : never : never> | (z.core.output<T_1> extends infer T_3 ? T_3 extends z.core.output<T_1> ? T_3 extends null ? void | T_3 | undefined : T_3 : never : never) : [T_1] extends [{
901
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
902
+ }] ? Promise<z.core.$InferObjectOutput<T_1, {}> extends infer T_4 ? T_4 extends z.core.$InferObjectOutput<T_1, {}> ? T_4 extends null ? void | T_4 | undefined : T_4 : never : never> | (z.core.$InferObjectOutput<T_1, {}> extends infer T_5 ? T_5 extends z.core.$InferObjectOutput<T_1, {}> ? T_5 extends null ? void | T_5 | undefined : T_5 : never : never) : any : never : never> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
903
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
904
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
905
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
906
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
907
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
908
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_6 ? T_6 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
909
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
910
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_6 extends Record<string, never> ? [{}] : [T_6] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_6, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_7 ? T_7 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_7 extends void ? Promise<any> : [T_7] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_7> extends infer T_8 ? T_8 extends z.core.output<T_7> ? T_8 extends null ? void | T_8 | undefined : T_8 : never : never> | (z.core.output<T_7> extends infer T_9 ? T_9 extends z.core.output<T_7> ? T_9 extends null ? void | T_9 | undefined : T_9 : never : never) : [T_7] extends [{
911
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
912
+ }] ? Promise<z.core.$InferObjectOutput<T_7, {}> extends infer T_10 ? T_10 extends z.core.$InferObjectOutput<T_7, {}> ? T_10 extends null ? void | T_10 | undefined : T_10 : never : never> | (z.core.$InferObjectOutput<T_7, {}> extends infer T_11 ? T_11 extends z.core.$InferObjectOutput<T_7, {}> ? T_11 extends null ? void | T_11 | undefined : T_11 : never : never) : any : never : never> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
913
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
914
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
915
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
916
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
917
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
918
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_12 ? T_12 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
919
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
920
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_12 extends Record<string, never> ? [{}] : [T_12] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_12, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_13 ? T_13 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_13 extends void ? Promise<any> : [T_13] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_13> extends infer T_14 ? T_14 extends z.core.output<T_13> ? T_14 extends null ? void | T_14 | undefined : T_14 : never : never> | (z.core.output<T_13> extends infer T_15 ? T_15 extends z.core.output<T_13> ? T_15 extends null ? void | T_15 | undefined : T_15 : never : never) : [T_13] extends [{
921
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
922
+ }] ? Promise<z.core.$InferObjectOutput<T_13, {}> extends infer T_16 ? T_16 extends z.core.$InferObjectOutput<T_13, {}> ? T_16 extends null ? void | T_16 | undefined : T_16 : never : never> | (z.core.$InferObjectOutput<T_13, {}> extends infer T_17 ? T_17 extends z.core.$InferObjectOutput<T_13, {}> ? T_17 extends null ? void | T_17 | undefined : T_17 : never : never) : any : never : never>) & CRPCFunctionTypeHint<InferClientInput<TInput>, TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>;
923
+ /** Mark as internal - returns chainable builder using internal function */
924
+ internal(): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
925
+ }
926
+ /**
927
+ * Action-specific procedure builder
928
+ * Only exposes .action() and .internalAction() methods
929
+ */
930
+ declare class ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends UnsetMarker | object = UnsetMarker, TInput extends UnsetMarker | z.ZodObject<any> = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends object = object> extends ProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta> {
931
+ /** Add middleware that transforms the context - $ContextOverridesOut is inferred from next() */
932
+ use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite$1<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<any, // Allow reusable middleware with any context
933
+ TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): ActionProcedureBuilder<TBaseCtx, TContext, Overwrite$1<TContextOverrides, $ContextOverridesOut>, TInput, TOutput, TMeta>;
934
+ /** Set procedure metadata (shallow merged when chained) */
935
+ meta(value: TMeta): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
936
+ /** Define input schema (chainable - schemas are merged) */
937
+ input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, TNewInput>, TOutput, TMeta>;
938
+ /** Define output schema */
939
+ output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TNewOutput, TMeta>;
940
+ /** Create an action */
941
+ action<TResult>(handler: (opts: {
942
+ ctx: Overwrite$1<TContext, TContextOverrides>;
943
+ input: InferInput<TInput>;
944
+ }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): (convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
945
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
946
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
947
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
948
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
949
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
950
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T ? T extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
951
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
952
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T extends Record<string, never> ? [{}] : [T] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_1 ? T_1 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_1 extends void ? Promise<any> : [T_1] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_1> extends infer T_2 ? T_2 extends z.core.output<T_1> ? T_2 extends null ? void | T_2 | undefined : T_2 : never : never> | (z.core.output<T_1> extends infer T_3 ? T_3 extends z.core.output<T_1> ? T_3 extends null ? void | T_3 | undefined : T_3 : never : never) : [T_1] extends [{
953
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
954
+ }] ? Promise<z.core.$InferObjectOutput<T_1, {}> extends infer T_4 ? T_4 extends z.core.$InferObjectOutput<T_1, {}> ? T_4 extends null ? void | T_4 | undefined : T_4 : never : never> | (z.core.$InferObjectOutput<T_1, {}> extends infer T_5 ? T_5 extends z.core.$InferObjectOutput<T_1, {}> ? T_5 extends null ? void | T_5 | undefined : T_5 : never : never) : any : never : never> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
955
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
956
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
957
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
958
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
959
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
960
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_6 ? T_6 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
961
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
962
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_6 extends Record<string, never> ? [{}] : [T_6] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_6, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_7 ? T_7 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_7 extends void ? Promise<any> : [T_7] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_7> extends infer T_8 ? T_8 extends z.core.output<T_7> ? T_8 extends null ? void | T_8 | undefined : T_8 : never : never> | (z.core.output<T_7> extends infer T_9 ? T_9 extends z.core.output<T_7> ? T_9 extends null ? void | T_9 | undefined : T_9 : never : never) : [T_7] extends [{
963
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
964
+ }] ? Promise<z.core.$InferObjectOutput<T_7, {}> extends infer T_10 ? T_10 extends z.core.$InferObjectOutput<T_7, {}> ? T_10 extends null ? void | T_10 | undefined : T_10 : never : never> | (z.core.$InferObjectOutput<T_7, {}> extends infer T_11 ? T_11 extends z.core.$InferObjectOutput<T_7, {}> ? T_11 extends null ? void | T_11 | undefined : T_11 : never : never) : any : never : never> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, convex_server0.ArgsArrayToObject<[TInput extends z.ZodObject<infer TShape extends Readonly<{
965
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
966
+ }>, z.core.$strip> ? TShape : Record<string, never>] extends [z.core.$ZodObject<any, z.core.$ZodObjectConfig>] ? [z.core.input<z.core.$ZodObject<any, z.core.$ZodObjectConfig> & (TInput extends z.ZodObject<infer TShape extends Readonly<{
967
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
968
+ }>, z.core.$strip> ? TShape : Record<string, never>)>] : (TInput extends z.ZodObject<infer TShape extends Readonly<{
969
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
970
+ }>, z.core.$strip> ? TShape : Record<string, never>) extends infer T_12 ? T_12 extends (TInput extends z.ZodObject<infer TShape extends Readonly<{
971
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
972
+ }>, z.core.$strip> ? TShape : Record<string, never>) ? T_12 extends Record<string, never> ? [{}] : [T_12] extends [Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>] ? [z.core.$InferObjectInput<T_12, {}>] : [convex_server0.DefaultFunctionArgs] : never : never>, (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) extends infer T_13 ? T_13 extends (TOutput extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> ? TOutput : never) ? T_13 extends void ? Promise<any> : [T_13] extends [z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>] ? Promise<z.core.output<T_13> extends infer T_14 ? T_14 extends z.core.output<T_13> ? T_14 extends null ? void | T_14 | undefined : T_14 : never : never> | (z.core.output<T_13> extends infer T_15 ? T_15 extends z.core.output<T_13> ? T_15 extends null ? void | T_15 | undefined : T_15 : never : never) : [T_13] extends [{
973
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
974
+ }] ? Promise<z.core.$InferObjectOutput<T_13, {}> extends infer T_16 ? T_16 extends z.core.$InferObjectOutput<T_13, {}> ? T_16 extends null ? void | T_16 | undefined : T_16 : never : never> | (z.core.$InferObjectOutput<T_13, {}> extends infer T_17 ? T_17 extends z.core.$InferObjectOutput<T_13, {}> ? T_17 extends null ? void | T_17 | undefined : T_17 : never : never) : any : never : never>) & CRPCFunctionTypeHint<InferClientInput<TInput>, TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>;
975
+ /** Mark as internal - returns chainable builder using internal function */
976
+ internal(): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
977
+ }
978
+ /** Return type for create() */
979
+ type CRPCInstance<_DataModel extends GenericDataModel, TQueryCtx, TMutationCtx, TActionCtx, THttpActionCtx, TMeta extends object = object> = {
980
+ query: QueryProcedureBuilder<TQueryCtx, TQueryCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta>;
981
+ mutation: MutationProcedureBuilder<TMutationCtx, TMutationCtx, UnsetMarker, UnsetMarker, UnsetMarker, TMeta>;
982
+ action: ActionProcedureBuilder<TActionCtx, TActionCtx, UnsetMarker, UnsetMarker, UnsetMarker, TMeta>;
983
+ httpAction: HttpProcedureBuilder<THttpActionCtx, THttpActionCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod>; /** Create reusable middleware - defaults to query context, override with generic */
984
+ middleware: <TContext = TQueryCtx, $ContextOverridesOut = object>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverridesOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverridesOut>; /** Create HTTP router (like tRPC's t.router) */
985
+ router: <TRecord extends HttpRouterRecord>(record: TRecord) => CRPCHttpRouter<TRecord>;
986
+ };
987
+ /**
988
+ * Builder with context configured, ready to create instance
989
+ */
990
+ declare class CRPCBuilderWithContext<DataModel extends GenericDataModel, TQueryCtx, TMutationCtx, TActionCtx = GenericActionCtx<DataModel>, THttpActionCtx = GenericActionCtx<DataModel>, TMeta extends object = object> {
991
+ private readonly contextConfig;
992
+ constructor(contextConfig: ContextConfig<DataModel>);
993
+ /**
994
+ * Define the metadata type for procedures (can be called after context)
995
+ */
996
+ meta<TNewMeta extends object>(): CRPCBuilderWithContext<DataModel, TQueryCtx, TMutationCtx, TActionCtx, THttpActionCtx, TNewMeta>;
997
+ /**
998
+ * Create the CRPC instance with function builders
999
+ */
1000
+ create(config?: CreateConfig<TMeta>): CRPCInstance<DataModel, TQueryCtx, TMutationCtx, TActionCtx, THttpActionCtx, TMeta>;
1001
+ }
1002
+ /**
1003
+ * Builder with meta type configured
1004
+ */
1005
+ declare class CRPCBuilderWithMeta<DataModel extends GenericDataModel, TMeta extends object = object> {
1006
+ /**
1007
+ * Configure context creators for each function type
1008
+ */
1009
+ context<TConfig extends ContextConfig<DataModel>>(config: TConfig): CRPCBuilderWithContext<DataModel, InferQueryCtx<TConfig, DataModel>, InferMutationCtx<TConfig, DataModel>, InferActionCtx<TConfig, DataModel>, InferActionCtx<TConfig, DataModel>, // httpAction uses action context
1010
+ TMeta>;
1011
+ /**
1012
+ * Create the CRPC instance directly (uses default passthrough context)
1013
+ */
1014
+ create(config?: CreateConfig<TMeta>): CRPCInstance<DataModel, GenericQueryCtx<DataModel>, GenericMutationCtx<DataModel>, GenericActionCtx<DataModel>, GenericActionCtx<DataModel>, // httpAction uses action context
1015
+ TMeta>;
1016
+ }
1017
+ /**
1018
+ * Initial CRPC builder - configure meta and context
1019
+ */
1020
+ declare class CRPCBuilder<DataModel extends GenericDataModel> {
1021
+ /**
1022
+ * Define the metadata type for procedures
1023
+ */
1024
+ meta<TMeta extends object>(): CRPCBuilderWithMeta<DataModel, TMeta>;
1025
+ /**
1026
+ * Configure context creators for each function type
1027
+ */
1028
+ context<TConfig extends ContextConfig<DataModel>>(config: TConfig): CRPCBuilderWithContext<DataModel, InferQueryCtx<TConfig, DataModel>, InferMutationCtx<TConfig, DataModel>, InferActionCtx<TConfig, DataModel>, InferActionCtx<TConfig, DataModel>>;
1029
+ /**
1030
+ * Create the CRPC instance directly (uses default passthrough context)
1031
+ */
1032
+ create(config?: CreateConfig<object>): CRPCInstance<DataModel, GenericQueryCtx<DataModel>, GenericMutationCtx<DataModel>, GenericActionCtx<DataModel>, GenericActionCtx<DataModel>, // httpAction uses action context
1033
+ object>;
1034
+ }
1035
+ /**
1036
+ * CRPC entry point - tRPC-style object
1037
+ *
1038
+ * @example
1039
+ * ```typescript
1040
+ * // With explicit DataModel type
1041
+ * const c = initCRPC
1042
+ * .dataModel<DataModel>()
1043
+ * .context({...})
1044
+ * .create();
1045
+ *
1046
+ * // Without DataModel (uses GenericDataModel)
1047
+ * const c = initCRPC
1048
+ * .context({...})
1049
+ * .create();
1050
+ * ```
1051
+ */
1052
+ declare const initCRPC: {
1053
+ /**
1054
+ * Set the DataModel type for the CRPC instance
1055
+ */
1056
+ dataModel<DataModel extends GenericDataModel>(): CRPCBuilder<DataModel>;
1057
+ /**
1058
+ * Define the metadata type (uses GenericDataModel)
1059
+ */
1060
+ meta<TMeta extends object>(): CRPCBuilderWithMeta<GenericDataModel, TMeta>;
1061
+ /**
1062
+ * Configure context creators (uses GenericDataModel)
1063
+ */
1064
+ context<TConfig extends ContextConfig<GenericDataModel>>(config: TConfig): CRPCBuilderWithContext<GenericDataModel, InferQueryCtx<TConfig, GenericDataModel>, InferMutationCtx<TConfig, GenericDataModel>, InferActionCtx<TConfig, GenericDataModel>, InferActionCtx<TConfig, GenericDataModel>>;
1065
+ /**
1066
+ * Create the CRPC instance directly (uses GenericDataModel and default passthrough context)
1067
+ */
1068
+ create(config?: CreateConfig<object>): CRPCInstance<GenericDataModel, GenericQueryCtx<GenericDataModel>, GenericMutationCtx<GenericDataModel>, GenericActionCtx<GenericDataModel>, GenericActionCtx<GenericDataModel>, // httpAction uses action context
1069
+ object>;
1070
+ };
1071
+ //#endregion
1072
+ //#region src/server/api-entry.d.ts
1073
+ type ApiFunctionType = 'query' | 'mutation' | 'action';
1074
+ type GeneratedFunctionVisibility = 'public' | 'internal';
1075
+ type InferArgsFromExport<TExport> = TExport extends CRPCFunctionTypeHint<infer TArgs, any> ? TArgs : TExport extends FunctionReference<any, any, infer TArgs, any> ? TArgs : TExport extends RegisteredQuery<any, infer TArgs, any> | RegisteredMutation<any, infer TArgs, any> | RegisteredAction<any, infer TArgs, any> ? TArgs : never;
1076
+ type InferReturnFromExport<TExport> = TExport extends CRPCFunctionTypeHint<any, infer TReturn> ? Awaited<TReturn> : TExport extends FunctionReference<any, any, any, infer TReturn> ? Awaited<TReturn> : TExport extends RegisteredQuery<any, any, infer TReturn> | RegisteredMutation<any, any, infer TReturn> | RegisteredAction<any, any, infer TReturn> ? Awaited<TReturn> : never;
1077
+ type CoerceArgs<TArgs> = TArgs extends DefaultFunctionArgs ? TArgs : TArgs extends Record<string, any> ? TArgs : Record<string, never>;
1078
+ type ApiFunctionRefFromExport<TType extends ApiFunctionType, TExport> = FunctionReference<TType, 'public', CoerceArgs<InferArgsFromExport<TExport>>, InferReturnFromExport<TExport>>;
1079
+ type GeneratedFunctionRefFromExport<TType extends ApiFunctionType, TVisibility extends GeneratedFunctionVisibility, TExport> = FunctionReference<TType, TVisibility, CoerceArgs<InferArgsFromExport<TExport>>, InferReturnFromExport<TExport>>;
1080
+ type ApiFunctionLeafMeta = {
1081
+ type: ApiFunctionType;
1082
+ auth?: 'required' | 'optional';
1083
+ [key: string]: unknown;
1084
+ };
1085
+ type CreateApiLeafArgs<TMeta extends ApiFunctionLeafMeta> = [fn: unknown, meta: TMeta] | [root: unknown, path: readonly string[], meta: TMeta];
1086
+ declare function getGeneratedValue<TValue = unknown>(root: unknown, path: readonly string[]): TValue;
1087
+ /**
1088
+ * Build a generated API leaf from a Convex FunctionReference name.
1089
+ * Returns a plain FunctionReference-compatible object with attached cRPC metadata.
1090
+ */
1091
+ declare function createApiLeaf<TType extends ApiFunctionType, TExport, TMeta extends ApiFunctionLeafMeta = ApiFunctionLeafMeta>(...args: CreateApiLeafArgs<TMeta>): ApiFunctionRefFromExport<TType, TExport> & TMeta & {
1092
+ functionRef: ApiFunctionRefFromExport<TType, TExport>;
1093
+ };
1094
+ declare function createGeneratedFunctionReference<TType extends ApiFunctionType, TVisibility extends GeneratedFunctionVisibility, TExport>(name: string): GeneratedFunctionRefFromExport<TType, TVisibility, TExport>;
1095
+ //#endregion
1096
+ //#region src/server/caller.d.ts
1097
+ /** Metadata for a single function */
1098
+ type FnMeta = {
1099
+ type?: 'query' | 'mutation' | 'action';
1100
+ [key: string]: unknown;
1101
+ };
1102
+ /** Metadata for all functions in a module */
1103
+ type ModuleMeta = Record<string, FnMeta>;
1104
+ /** Metadata for all modules - from generated `@convex/api` */
1105
+ type CallerMeta = Record<string, ModuleMeta>;
1106
+ /** Options for individual caller function calls */
1107
+ type CallerOpts = {
1108
+ /** Skip query silently when unauthenticated (returns null instead of throwing) */skipUnauth?: boolean;
1109
+ };
1110
+ type CallerReturn<T, Opts extends CallerOpts | undefined> = Opts extends {
1111
+ skipUnauth: true;
1112
+ } ? T | null : T;
1113
+ type FetchFn<T extends 'query' | 'mutation' | 'action'> = <Fn extends FunctionReference<T>>(fn: Fn, args: Fn['_args'], opts?: CallerOpts) => Promise<FunctionReturnType<Fn> | null>;
1114
+ type CreateCallerOptions = {
1115
+ fetchQuery: FetchFn<'query'>;
1116
+ fetchMutation: FetchFn<'mutation'>;
1117
+ fetchAction: FetchFn<'action'>;
1118
+ meta: CallerMeta;
1119
+ transformer?: DataTransformerOptions;
1120
+ };
1121
+ type ServerCallerFn<TApi, K extends keyof TApi> = TApi[K] extends FunctionReference<infer T, 'public'> ? T extends 'query' | 'mutation' | 'action' ? keyof TApi[K]['_args'] extends never ? <Opts extends CallerOpts | undefined = undefined>(args?: EmptyObject, opts?: Opts) => Promise<CallerReturn<FunctionReturnType<TApi[K]>, Opts>> : EmptyObject extends TApi[K]['_args'] ? <Opts extends CallerOpts | undefined = undefined>(args?: TApi[K]['_args'], opts?: Opts) => Promise<CallerReturn<FunctionReturnType<TApi[K]>, Opts>> : <Opts extends CallerOpts | undefined = undefined>(args: TApi[K]['_args'], opts?: Opts) => Promise<CallerReturn<FunctionReturnType<TApi[K]>, Opts>> : never : ServerCaller<TApi[K]>;
1122
+ type ServerCaller<TApi> = { [K in keyof TApi as K extends string ? K extends `_${string}` ? never : K extends 'http' ? never : K : K]: ServerCallerFn<TApi, K> };
1123
+ /**
1124
+ * Create a server caller for direct data fetching without React Query.
1125
+ *
1126
+ * This is detached from React Query cache - data is NOT available in client components.
1127
+ * Use for server-only data that doesn't need to be shared with the client.
1128
+ *
1129
+ * @example
1130
+ * ```tsx
1131
+ * // src/lib/convex/rsc.tsx
1132
+ * export const caller = createServerCaller(api, {
1133
+ * fetchQuery: fetchAuthQuery,
1134
+ * fetchMutation: fetchAuthMutation,
1135
+ * });
1136
+ *
1137
+ * // app/page.tsx (RSC)
1138
+ * const posts = await caller.posts.list();
1139
+ * return <div>{posts?.length} posts</div>;
1140
+ * ```
1141
+ */
1142
+ declare function createServerCaller<TApi extends Record<string, unknown>>(api: TApi, opts: CreateCallerOptions): ServerCaller<TApi>;
1143
+ //#endregion
1144
+ //#region src/server/lazy-caller.d.ts
1145
+ type CallerContext<TApi> = {
1146
+ caller: ServerCaller<TApi>;
1147
+ token: string | undefined;
1148
+ isAuthenticated: boolean;
1149
+ };
1150
+ /**
1151
+ * Lazy caller with auth helper methods.
1152
+ * Context is created on first procedure invocation, not at definition time.
1153
+ */
1154
+ type LazyCaller<TApi> = ServerCaller<TApi> & {
1155
+ /** Check if user is authenticated */isAuth: () => Promise<boolean>; /** Check if user is unauthenticated */
1156
+ isUnauth: () => Promise<boolean>; /** Get the auth token (for RSC prefetching) */
1157
+ getToken: () => Promise<string | undefined>;
1158
+ };
1159
+ /**
1160
+ * Create a lazy caller that creates context on each procedure invocation.
1161
+ * Matches tRPC's `appRouter.createCaller(createTRPCContext)` pattern.
1162
+ *
1163
+ * @example
1164
+ * ```ts
1165
+ * // server.ts
1166
+ * const { createContext, createCaller } = createCallerFactory({...});
1167
+ *
1168
+ * // rsc.tsx
1169
+ * const createRSCContext = cache(async () => {
1170
+ * const heads = await headers();
1171
+ * return createContext({ headers: heads });
1172
+ * });
1173
+ * export const caller = createCaller(createRSCContext);
1174
+ *
1175
+ * // app/page.tsx - single call! Context created lazily
1176
+ * const posts = await caller.posts.list();
1177
+ * ```
1178
+ */
1179
+ declare function createLazyCaller<TApi extends Record<string, unknown>>(api: TApi, createContext: () => Promise<CallerContext<TApi>>): LazyCaller<TApi>;
1180
+ //#endregion
1181
+ //#region src/server/caller-factory.d.ts
1182
+ type TokenResult = {
1183
+ token?: string;
1184
+ isFresh?: boolean;
1185
+ };
1186
+ type GetTokenFn = (siteUrl: string, headers: Headers, opts?: unknown) => Promise<TokenResult>;
1187
+ /** Auth options for server-side calls. */
1188
+ type AuthOptions = {
1189
+ /** Function to extract auth token from request headers. */getToken: GetTokenFn; /** Custom function to detect UNAUTHORIZED errors. Default checks code property. */
1190
+ isUnauthorized?: (error: unknown) => boolean;
1191
+ };
1192
+ type CreateCallerFactoryOptions<TApi> = {
1193
+ /** Your Convex API object. */api: TApi; /** Convex site URL (must end in `.convex.site`). */
1194
+ convexSiteUrl: string;
1195
+ /**
1196
+ * Convex deployment URL (must end in `.convex.cloud`).
1197
+ * Defaults to `convexSiteUrl` with the domain swapped.
1198
+ */
1199
+ convexUrl?: string; /** Auth options. Pass to enable authenticated calls with JWT caching. */
1200
+ auth?: AuthOptions; /** Optional wire transformer for request/response payloads (always composed with Date). */
1201
+ transformer?: DataTransformerOptions;
1202
+ };
1203
+ type ConvexContext<TApi> = {
1204
+ token: string | undefined;
1205
+ isAuthenticated: boolean;
1206
+ caller: ServerCaller<TApi>;
1207
+ };
1208
+ declare function createCallerFactory<TApi extends Record<string, unknown>>(opts: CreateCallerFactoryOptions<TApi>): {
1209
+ createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
1210
+ createContext: (reqOpts: {
1211
+ headers: Headers;
1212
+ }) => Promise<ConvexContext<TApi>>;
1213
+ };
1214
+ //#endregion
1215
+ //#region src/server/env.d.ts
1216
+ type RuntimeEnv = Record<string, string | undefined>;
1217
+ type CreateEnvOptions<TSchema extends z.ZodObject<z.ZodRawShape>> = {
1218
+ cache?: boolean;
1219
+ codegenFallback?: boolean;
1220
+ runtimeEnv?: RuntimeEnv;
1221
+ schema: TSchema;
1222
+ };
1223
+ declare function createEnv<TSchema extends z.ZodObject<z.ZodRawShape>>(options: CreateEnvOptions<TSchema>): () => z.infer<TSchema>;
1224
+ //#endregion
1225
+ //#region src/server/error.d.ts
1226
+ /** JSON-RPC 2.0 error codes (tRPC-style) */
1227
+ declare const CRPC_ERROR_CODES_BY_KEY: {
1228
+ readonly PARSE_ERROR: -32700;
1229
+ readonly BAD_REQUEST: -32600;
1230
+ readonly INTERNAL_SERVER_ERROR: -32603;
1231
+ readonly NOT_IMPLEMENTED: -32603;
1232
+ readonly BAD_GATEWAY: -32603;
1233
+ readonly SERVICE_UNAVAILABLE: -32603;
1234
+ readonly GATEWAY_TIMEOUT: -32603;
1235
+ readonly UNAUTHORIZED: -32001;
1236
+ readonly PAYMENT_REQUIRED: -32002;
1237
+ readonly FORBIDDEN: -32003;
1238
+ readonly NOT_FOUND: -32004;
1239
+ readonly METHOD_NOT_SUPPORTED: -32005;
1240
+ readonly TIMEOUT: -32008;
1241
+ readonly CONFLICT: -32009;
1242
+ readonly PRECONDITION_FAILED: -32012;
1243
+ readonly PAYLOAD_TOO_LARGE: -32013;
1244
+ readonly UNSUPPORTED_MEDIA_TYPE: -32015;
1245
+ readonly UNPROCESSABLE_CONTENT: -32022;
1246
+ readonly PRECONDITION_REQUIRED: -32028;
1247
+ readonly TOO_MANY_REQUESTS: -32029;
1248
+ readonly CLIENT_CLOSED_REQUEST: -32099;
1249
+ };
1250
+ type CRPCErrorCode = keyof typeof CRPC_ERROR_CODES_BY_KEY;
1251
+ /** Map error codes to HTTP status codes */
1252
+ declare const CRPC_ERROR_CODE_TO_HTTP: Record<CRPCErrorCode, number>;
1253
+ type CRPCErrorData = {
1254
+ code: CRPCErrorCode;
1255
+ message: string;
1256
+ };
1257
+ /**
1258
+ * tRPC-style error extending ConvexError
1259
+ *
1260
+ * @example
1261
+ * ```typescript
1262
+ * throw new CRPCError({
1263
+ * code: 'BAD_REQUEST',
1264
+ * message: 'Invalid input',
1265
+ * cause: originalError,
1266
+ * });
1267
+ * ```
1268
+ */
1269
+ declare class CRPCError extends ConvexError<CRPCErrorData> {
1270
+ readonly code: CRPCErrorCode;
1271
+ readonly cause?: Error;
1272
+ constructor(opts: {
1273
+ code: CRPCErrorCode;
1274
+ message?: string;
1275
+ cause?: unknown;
1276
+ });
1277
+ }
1278
+ /**
1279
+ * Convert known framework/library errors into CRPCError.
1280
+ *
1281
+ * Intended for cRPC internals so callers don't need per-endpoint try/catch.
1282
+ */
1283
+ declare function toCRPCError(cause: unknown): CRPCError | null;
1284
+ /**
1285
+ * Wrap unknown error in CRPCError (from tRPC)
1286
+ *
1287
+ * @example
1288
+ * ```typescript
1289
+ * try {
1290
+ * await someOperation();
1291
+ * } catch (error) {
1292
+ * throw getCRPCErrorFromUnknown(error);
1293
+ * }
1294
+ * ```
1295
+ */
1296
+ declare function getCRPCErrorFromUnknown(cause: unknown): CRPCError;
1297
+ /**
1298
+ * Get HTTP status code from CRPCError
1299
+ *
1300
+ * @example
1301
+ * ```typescript
1302
+ * const httpStatus = getHTTPStatusCodeFromError(error); // 400
1303
+ * ```
1304
+ */
1305
+ declare function getHTTPStatusCodeFromError(error: CRPCError): number;
1306
+ /** Type guard for CRPCError */
1307
+ declare function isCRPCError(error: unknown): error is CRPCError;
1308
+ //#endregion
1309
+ //#region src/server/infer.d.ts
1310
+ /**
1311
+ * Combine a Convex API with an HTTP router for unified type inference.
1312
+ *
1313
+ * @example
1314
+ * ```ts
1315
+ * import type { WithHttpRouter } from 'kitcn/server';
1316
+ *
1317
+ * export type AppRouter = WithHttpRouter<typeof api, typeof httpRouter>;
1318
+ * export type ApiInputs = inferApiInputs<AppRouter>;
1319
+ * // ApiInputs['http']['todos']['create'] works
1320
+ * ```
1321
+ */
1322
+ type WithHttpRouter<TApi, TRouter> = TApi & {
1323
+ http?: TRouter;
1324
+ };
1325
+ /** Helper to unwrap optional/nullable types for inference */
1326
+ type UnwrapOptional<T> = T extends undefined ? never : NonNullable<T>;
1327
+ type PublicApiKey<K> = K extends string ? K extends `_${string}` ? never : K : K;
1328
+ /** Recursive output inference that handles optional properties */
1329
+ type InferOutputsRecursive<T> = T extends FunctionReference<infer _T, 'public'> ? FunctionReturnType<T> : T extends HttpProcedure ? InferHttpOutput<T> : T extends CRPCHttpRouter<infer R> ? inferApiOutputs<R> : T extends HttpRouterRecord ? inferApiOutputs<T> : inferApiOutputs<T>;
1330
+ /**
1331
+ * Infer all output types from a Convex API (including HTTP routes).
1332
+ * Optional properties (like `http?`) are unwrapped for easier access.
1333
+ *
1334
+ * @example
1335
+ * ```ts
1336
+ * import { api } from '@convex/api';
1337
+ * import type { inferApiOutputs } from 'kitcn/server';
1338
+ *
1339
+ * type AppRouter = typeof api & { http?: typeof httpRouter };
1340
+ * type ApiOutputs = inferApiOutputs<AppRouter>;
1341
+ *
1342
+ * type LinkData = ApiOutputs['scraper']['scrapeLink'];
1343
+ * type TodoList = ApiOutputs['http']['todos']['list'];
1344
+ * ```
1345
+ */
1346
+ type inferApiOutputs<TApi> = { [K in keyof TApi as PublicApiKey<K>]-?: InferOutputsRecursive<UnwrapOptional<TApi[K]>> };
1347
+ /** Recursive input inference that handles optional properties */
1348
+ type InferInputsRecursive<T> = T extends FunctionReference<infer _T, 'public'> ? T['_args'] : T extends HttpProcedure ? InferHttpInput<T> : T extends CRPCHttpRouter<infer R> ? inferApiInputs<R> : T extends HttpRouterRecord ? inferApiInputs<T> : inferApiInputs<T>;
1349
+ /**
1350
+ * Infer all input types from a Convex API (including HTTP routes).
1351
+ * Optional properties (like `http?`) are unwrapped for easier access.
1352
+ *
1353
+ * @example
1354
+ * ```ts
1355
+ * import { api } from '@convex/api';
1356
+ * import type { inferApiInputs } from 'kitcn/server';
1357
+ *
1358
+ * type AppRouter = typeof api & { http?: typeof httpRouter };
1359
+ * type ApiInputs = inferApiInputs<AppRouter>;
1360
+ *
1361
+ * type ScrapeLinkInput = ApiInputs['scraper']['scrapeLink'];
1362
+ * type CreateTodoInput = ApiInputs['http']['todos']['create'];
1363
+ * ```
1364
+ */
1365
+ type inferApiInputs<TApi> = { [K in keyof TApi as PublicApiKey<K>]-?: InferInputsRecursive<UnwrapOptional<TApi[K]>> };
1366
+ //#endregion
1367
+ //#region src/server/procedure-caller.d.ts
1368
+ type ProcedureType = 'query' | 'mutation' | 'action';
1369
+ type CallerContextType = 'query' | 'mutation';
1370
+ type ScheduledFunctionId = GenericId<'_scheduled_functions'>;
1371
+ type RecordLike = Record<string, unknown>;
1372
+ type ProcedureTree = RecordLike;
1373
+ type ProcedureDefinition<TType extends ProcedureType, TProcedure> = Readonly<{
1374
+ _type: TType;
1375
+ __procedure?: TProcedure;
1376
+ }>;
1377
+ type ProcedureHandlerType<TProcedure> = NonNullable<TProcedure extends {
1378
+ _handler?: infer THandler;
1379
+ } ? THandler : never>;
1380
+ type ProcedureTypeHintInput<TProcedure> = TProcedure extends {
1381
+ __kitcnTypeHint?: {
1382
+ args: infer TArgs;
1383
+ };
1384
+ } ? TArgs : never;
1385
+ type ProcedureTypeHintOutput<TProcedure> = TProcedure extends {
1386
+ __kitcnTypeHint?: {
1387
+ returns: infer TReturns;
1388
+ };
1389
+ } ? TReturns : never;
1390
+ type InferredHandlerInput<TProcedure> = ProcedureHandlerType<TProcedure> extends ((ctx: unknown, input: infer TInput, ...rest: any[]) => unknown) ? TInput : Record<string, never>;
1391
+ type InferredHandlerOutput<TProcedure> = ProcedureHandlerType<TProcedure> extends ((...args: any[]) => infer TResult) ? Awaited<TResult> : never;
1392
+ type ProcedureInput<TProcedure> = [ProcedureTypeHintInput<TProcedure>] extends [never] ? InferredHandlerInput<TProcedure> : ProcedureTypeHintInput<TProcedure>;
1393
+ type ProcedureOutput<TProcedure> = [ProcedureTypeHintOutput<TProcedure>] extends [never] ? InferredHandlerOutput<TProcedure> : ProcedureTypeHintOutput<TProcedure>;
1394
+ type ProcedureCallableWithOutput<TProcedure, TOutput> = keyof ProcedureInput<TProcedure> extends never ? (input?: EmptyObject) => Promise<TOutput> : EmptyObject extends ProcedureInput<TProcedure> ? (input?: ProcedureInput<TProcedure>) => Promise<TOutput> : (input: ProcedureInput<TProcedure>) => Promise<TOutput>;
1395
+ type ProcedureCallable<TProcedure> = ProcedureCallableWithOutput<TProcedure, ProcedureOutput<TProcedure>>;
1396
+ type ProcedureSchedulableCallable<TProcedure> = ProcedureCallableWithOutput<TProcedure, ScheduledFunctionId>;
1397
+ type SchedulableProcedureType = Exclude<ProcedureType, 'query'>;
1398
+ type AllowedProcedureType<TCtxType extends CallerContextType> = TCtxType extends 'query' ? 'query' : 'query' | 'mutation';
1399
+ type CallerKey<TValue, TCtxType extends CallerContextType, TKey extends PropertyKey> = TValue extends ProcedureDefinition<infer TType, any> ? TType extends AllowedProcedureType<TCtxType> ? TKey : never : TValue extends RecordLike ? TKey : never;
1400
+ type ProcedureCaller<TApi, TCtxType extends CallerContextType> = TApi extends RecordLike ? { [K in keyof TApi as CallerKey<TApi[K], TCtxType, K>]: TApi[K] extends ProcedureDefinition<any, infer TProcedure> ? ProcedureCallable<TProcedure> : TApi[K] extends RecordLike ? ProcedureCaller<TApi[K], TCtxType> : never } : never;
1401
+ type CallerForContext<TApi, TCtx, TQueryCtx, TMutationCtx> = TCtx extends TMutationCtx ? ProcedureCaller<TApi, 'mutation'> : TCtx extends TQueryCtx ? ProcedureCaller<TApi, 'query'> : never;
1402
+ type UnionToIntersection<TUnion> = (TUnion extends unknown ? (value: TUnion) => void : never) extends ((value: infer TIntersection) => void) ? TIntersection : never;
1403
+ type Simplify<TObject> = { [K in keyof TObject]: TObject[K] } & {};
1404
+ type SimplifyDeep<TObject> = TObject extends Record<string, unknown> ? Simplify<{ [K in keyof TObject]: SimplifyDeep<TObject[K]> }> : TObject;
1405
+ type SplitPath<TPath extends string> = TPath extends `${infer THead}.${infer TRest}` ? [THead, ...SplitPath<TRest>] : TPath extends '' ? [] : [TPath];
1406
+ type BuildPathShape<TSegments extends string[], TValue> = TSegments extends [infer THead extends string, ...infer TRest extends string[]] ? { [K in THead]: TRest['length'] extends 0 ? TValue : BuildPathShape<TRest, TValue> } : never;
1407
+ type ResolverOutput<TResolver> = TResolver extends ((...args: any[]) => infer TResult) ? Awaited<TResult> : never;
1408
+ type RegistryEntryToPathShape<TPath extends string, TEntry, TAllowed extends ProcedureType> = TEntry extends readonly [infer TType extends ProcedureType, infer TResolver] ? TType extends TAllowed ? BuildPathShape<SplitPath<TPath>, ProcedureCallable<ResolverOutput<Extract<TResolver, (...args: any[]) => unknown>>>> : {} : {};
1409
+ type RegistryEntryToSchedulablePathShape<TPath extends string, TEntry, TAllowed extends ProcedureType> = TEntry extends readonly [infer TType extends ProcedureType, infer TResolver] ? TType extends TAllowed ? BuildPathShape<SplitPath<TPath>, ProcedureSchedulableCallable<ResolverOutput<Extract<TResolver, (...args: any[]) => unknown>>>> : {} : {};
1410
+ type GeneratedProcedureRegistryEntry<TType extends ProcedureType = ProcedureType, TResolver extends (...args: any[]) => unknown = (...args: any[]) => unknown> = readonly [TType, TResolver];
1411
+ type GeneratedProcedureRegistry = Record<string, GeneratedProcedureRegistryEntry>;
1412
+ type ProcedureCallerFromRegistryByAllowedTypes<TRegistry extends GeneratedProcedureRegistry, TAllowed extends ProcedureType> = SimplifyDeep<UnionToIntersection<{ [K in keyof TRegistry & string]: RegistryEntryToPathShape<K, TRegistry[K], TAllowed> }[keyof TRegistry & string]>>;
1413
+ type ProcedureCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry, TCtxType extends CallerContextType> = TCtxType extends 'query' ? ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query'> : ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query' | 'mutation'>;
1414
+ type ProcedureActionCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry> = ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'action'>;
1415
+ type ProcedureSchedulableCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry> = SimplifyDeep<UnionToIntersection<{ [K in keyof TRegistry & string]: RegistryEntryToSchedulablePathShape<K, TRegistry[K], SchedulableProcedureType> }[keyof TRegistry & string]>>;
1416
+ type ProcedureScheduleCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry> = {
1417
+ after: (delayMs: number) => ProcedureSchedulableCallerFromRegistry<TRegistry>;
1418
+ at: (timestamp: number | Date) => ProcedureSchedulableCallerFromRegistry<TRegistry>;
1419
+ now: ProcedureSchedulableCallerFromRegistry<TRegistry>;
1420
+ cancel: (id: ScheduledFunctionId) => Promise<void>;
1421
+ };
1422
+ type ProcedureMutationCallerWithSchedule<TRegistry extends GeneratedProcedureRegistry> = SimplifyDeep<ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query' | 'mutation'> & {
1423
+ schedule: ProcedureScheduleCallerFromRegistry<TRegistry>;
1424
+ }>;
1425
+ type ProcedureActionCallerWithNamespaces<TRegistry extends GeneratedProcedureRegistry> = SimplifyDeep<ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query' | 'mutation'> & {
1426
+ actions: ProcedureActionCallerFromRegistry<TRegistry>;
1427
+ schedule: ProcedureScheduleCallerFromRegistry<TRegistry>;
1428
+ }>;
1429
+ type GeneratedRegistryCallerForContext<TRegistry extends GeneratedProcedureRegistry, TCtx, TQueryCtx, TMutationCtx, TActionCtx = never> = TCtx extends TMutationCtx ? ProcedureMutationCallerWithSchedule<TRegistry> : TCtx extends TActionCtx ? ProcedureActionCallerWithNamespaces<TRegistry> : TCtx extends TQueryCtx ? ProcedureCallerFromRegistry<TRegistry, 'query'> : never;
1430
+ type GeneratedRegistryHandlerForContext<TRegistry extends GeneratedProcedureRegistry, TCtx, TQueryCtx, TMutationCtx> = TCtx extends TMutationCtx ? ProcedureCallerFromRegistry<TRegistry, 'mutation'> : TCtx extends TQueryCtx ? ProcedureCallerFromRegistry<TRegistry, 'query'> : never;
1431
+ type CreateProcedureCallerFactoryOptions<TApi extends ProcedureTree> = {
1432
+ api: TApi;
1433
+ resolver: (path: string[]) => Promise<unknown> | unknown;
1434
+ };
1435
+ type AnyProcedureFunctionReference = FunctionReference<'query' | 'mutation' | 'action', any, any, any>;
1436
+ type ProcedureTypeFromFunctionReference<TFunctionReference extends AnyProcedureFunctionReference> = TFunctionReference extends FunctionReference<infer TProcedureType, any, any, any> ? TProcedureType extends ProcedureType ? TProcedureType : never : never;
1437
+ type ProcedureFromFunctionReference<TFunctionReference extends AnyProcedureFunctionReference> = CRPCFunctionTypeHint<TFunctionReference['_args'], FunctionReturnType<TFunctionReference>> & {
1438
+ _crpcMeta?: {
1439
+ type?: ProcedureTypeFromFunctionReference<TFunctionReference>;
1440
+ };
1441
+ _handler?: (ctx: unknown, input: TFunctionReference['_args']) => FunctionReturnType<TFunctionReference> | Promise<FunctionReturnType<TFunctionReference>>;
1442
+ };
1443
+ type ProcedureResolverFromFunctionReference<TFunctionReference extends AnyProcedureFunctionReference> = () => ProcedureFromFunctionReference<TFunctionReference> | Promise<ProcedureFromFunctionReference<TFunctionReference>>;
1444
+ declare function typedProcedureResolver<TFunctionReference extends AnyProcedureFunctionReference>(functionReference: TFunctionReference, resolver: () => unknown | Promise<unknown>): ProcedureResolverFromFunctionReference<TFunctionReference>;
1445
+ declare function getGeneratedFunctionReference<TFunctionReference extends AnyProcedureFunctionReference>(functionReference: TFunctionReference): TFunctionReference;
1446
+ declare function defineProcedure<TType extends ProcedureType, TProcedure>(type: TType): ProcedureDefinition<TType, TProcedure>;
1447
+ declare function createProcedureCallerFactory<TQueryCtx, TMutationCtx, TApi extends ProcedureTree>(opts: CreateProcedureCallerFactoryOptions<TApi>): <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => CallerForContext<TApi, TCtx, TQueryCtx, TMutationCtx>;
1448
+ declare function createProcedureHandlerFactory<TQueryCtx, TMutationCtx, TApi extends ProcedureTree>(opts: CreateProcedureCallerFactoryOptions<TApi>): <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => CallerForContext<TApi, TCtx, TQueryCtx, TMutationCtx>;
1449
+ declare function createGenericCallerFactory<TQueryCtx, TMutationCtx, TRegistry extends GeneratedProcedureRegistry, TActionCtx = never>(registry: TRegistry): <TCtx extends TQueryCtx | TMutationCtx | TActionCtx>(ctx: TCtx) => GeneratedRegistryCallerForContext<TRegistry, TCtx, TQueryCtx, TMutationCtx, TActionCtx>;
1450
+ declare function createGenericHandlerFactory<TQueryCtx, TMutationCtx, TRegistry extends GeneratedProcedureRegistry>(registry: TRegistry): <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => GeneratedRegistryHandlerForContext<TRegistry, TCtx, TQueryCtx, TMutationCtx>;
1451
+ type GeneratedRegistryCallerFactory<TQueryCtx, TMutationCtx, TRegistry extends GeneratedProcedureRegistry, TActionCtx = never> = <TCtx extends TQueryCtx | TMutationCtx | TActionCtx>(ctx: TCtx) => GeneratedRegistryCallerForContext<TRegistry, TCtx, TQueryCtx, TMutationCtx, TActionCtx>;
1452
+ type GeneratedRegistryHandlerFactory<TQueryCtx, TMutationCtx, TRegistry extends GeneratedProcedureRegistry> = <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => GeneratedRegistryHandlerForContext<TRegistry, TCtx, TQueryCtx, TMutationCtx>;
1453
+ type GeneratedRegistryRuntime<TQueryCtx, TMutationCtx, TCallerRegistry extends GeneratedProcedureRegistry, TActionCtx = never> = {
1454
+ getCallerFactory: () => GeneratedRegistryCallerFactory<TQueryCtx, TMutationCtx, TCallerRegistry, TActionCtx>;
1455
+ };
1456
+ type GeneratedRegistryRuntimeWithHandler<TQueryCtx, TMutationCtx, TCallerRegistry extends GeneratedProcedureRegistry, THandlerRegistry extends GeneratedProcedureRegistry, TActionCtx = never> = GeneratedRegistryRuntime<TQueryCtx, TMutationCtx, TCallerRegistry, TActionCtx> & {
1457
+ getHandlerFactory: () => GeneratedRegistryHandlerFactory<TQueryCtx, TMutationCtx, THandlerRegistry>;
1458
+ };
1459
+ type GeneratedRegistryBundle<TCallerRegistry extends GeneratedProcedureRegistry, THandlerRegistry extends GeneratedProcedureRegistry | undefined = undefined> = {
1460
+ procedureRegistry: TCallerRegistry;
1461
+ handlerRegistry?: THandlerRegistry;
1462
+ };
1463
+ type GeneratedRegistrySource<TCallerRegistry extends GeneratedProcedureRegistry, THandlerRegistry extends GeneratedProcedureRegistry | undefined = undefined> = GeneratedRegistryBundle<TCallerRegistry, THandlerRegistry> | (() => GeneratedRegistryBundle<TCallerRegistry, THandlerRegistry>);
1464
+ type GeneratedRegistryRuntimeResult<TQueryCtx, TMutationCtx, TCallerRegistry extends GeneratedProcedureRegistry, TActionCtx, THandlerRegistry extends GeneratedProcedureRegistry | undefined> = THandlerRegistry extends GeneratedProcedureRegistry ? GeneratedRegistryRuntimeWithHandler<TQueryCtx, TMutationCtx, TCallerRegistry, Exclude<THandlerRegistry, undefined>, TActionCtx> : GeneratedRegistryRuntime<TQueryCtx, TMutationCtx, TCallerRegistry, TActionCtx>;
1465
+ declare function createGeneratedRegistryRuntime<TQueryCtx, TMutationCtx, TCallerRegistry extends GeneratedProcedureRegistry, TActionCtx = never, THandlerRegistry extends GeneratedProcedureRegistry | undefined = undefined>(createRegistryOrRegistry: GeneratedRegistrySource<TCallerRegistry, THandlerRegistry>): GeneratedRegistryRuntimeResult<TQueryCtx, TMutationCtx, TCallerRegistry, TActionCtx, THandlerRegistry>;
1466
+ //#endregion
1467
+ export { initCRPC as $, getCRPCErrorFromUnknown as A, CallerMeta as B, WithHttpRouter as C, CRPCErrorCode as D, CRPCError as E, createEnv as F, createGeneratedFunctionReference as G, ServerCaller as H, ConvexContext as I, CRPCFunctionTypeHint as J, getGeneratedValue as K, createCallerFactory as L, isCRPCError as M, toCRPCError as N, CRPC_ERROR_CODES_BY_KEY as O, CreateEnvOptions as P, createMiddlewareFactory as Q, LazyCaller as R, typedProcedureResolver as S, zodToConvexFields as St, inferApiOutputs as T, createServerCaller as U, CallerOpts as V, createApiLeaf as W, ProcedureBuilder as X, MutationProcedureBuilder as Y, QueryProcedureBuilder as Z, createGenericHandlerFactory as _, zCustomQuery as _t, GeneratedRegistryCallerForContext as a, ConvexValidatorFromZod as at, defineProcedure as b, zodOutputToConvexFields as bt, ProcedureActionCallerFromRegistry as c, ZCustomCtx as ct, ProcedureDefinition as d, ZodValidatorFromConvex as dt, HttpProcedureBuilder as et, ProcedureFromFunctionReference as f, convexToZod as ft, createGenericCallerFactory as g, zCustomMutation as gt, createGeneratedRegistryRuntime as h, zCustomAction as ht, GeneratedRegistryCallerFactory as i, matchPathParams as it, getHTTPStatusCodeFromError as j, CRPC_ERROR_CODE_TO_HTTP as k, ProcedureCaller as l, Zid as lt, ProcedureScheduleCallerFromRegistry as m, withSystemFields as mt, GeneratedProcedureRegistry as n, extractPathParams as nt, GeneratedRegistryHandlerFactory as o, ConvexValidatorFromZodOutput as ot, ProcedureSchedulableCallerFromRegistry as p, convexToZodFields as pt, ActionProcedureBuilder as q, GeneratedProcedureRegistryEntry as r, handleHttpError as rt, GeneratedRegistryHandlerForContext as s, CustomBuilder as st, CreateProcedureCallerFactoryOptions as t, createHttpProcedureBuilder as tt, ProcedureCallerFromRegistry as u, ZodFromValidatorBase as ut, createProcedureCallerFactory as v, zid as vt, inferApiInputs as w, getGeneratedFunctionReference as x, zodToConvex as xt, createProcedureHandlerFactory as y, zodOutputToConvex as yt, createLazyCaller as z };