import { t as VRequired } from "./validators-BhsByJeg.js";
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-zsMHb_QN.js";
import { g as UnsetMarker, i as IntersectIfDefined, o as MiddlewareBuilder, p as Overwrite$1, s as MiddlewareFunction, t as AnyMiddleware } from "./types-CnTpHR1F.js";
import { ConvexError, GenericId, GenericValidator, ObjectType, OptionalProperty, PropertyValidators, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion, Validator, Value as Value$1 } from "convex/values";
import { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionReference, FunctionReturnType, FunctionVisibility, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, MutationBuilder, QueryBuilder, RegisteredAction, RegisteredMutation, RegisteredQuery, TableNamesInDataModel } from "convex/server";
import { z } from "zod";
import * as z$1 from "zod/v4";
import * as zCore from "zod/v4/core";

//#region src/internal/upstream/index.d.ts
type EmptyObject = Record<string, never>;
/**
 * Hack! This type causes TypeScript to simplify how it renders object types.
 *
 * It is functionally the identity for object types, but in practice it can
 * simplify expressions like `A & B`.
 */
type Expand<ObjectType extends Record<any, any>> = ObjectType extends Record<any, any> ? { [Key in keyof ObjectType]: ObjectType[Key] } : never;
//#endregion
//#region src/internal/upstream/server/customFunctions.d.ts
/**
 * A customization of a query, mutation, or action.
 *
 * It can specify common arguments that all defined functions take in,
 * as well as modify the ctx and args arguments to each function.
 *
 * Generally it's defined inline with customQuery, customMutation, etc.
 * But you can define the type explicitly if you want to reuse it.
 *
 * e.g.
 * ```ts
 * const myCustomization: Customization<
 * QueryCtx,
 * { sessionId: VId<"sessions"> },
 * { db: DatabaseReader, user: User, session: Session },
 * {},
 * > = {
 *   args: { sessionId: v.id("sessions") },
 *   input: async (ctx, args) => {
 *     const user = await getUserOrNull(ctx);
 *     const session = await db.get(sessionId);
 *     const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
 *     return { ctx: { db, user, session }, args: {} };
 *   },
 * };
 *
 * const myQueryBuilder = customQuery(query, myCustomization);
 * ```
 *
 * If the required args are not returned, they will not be provided for the
 * modified function. All returned ctx and args will show up in the type
 * signature for the modified function. To remove something from `ctx`, you
 * can return it as `undefined`.

 *  The `input` function can also return an `onSuccess` callback that will be
 * called after the function executes successfully. The `onSuccess` callback
 * has access to resources created during input processing via closure.
 */
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>> = {
  args: CustomArgsValidator;
  input: (ctx: Ctx, args: ObjectType<CustomArgsValidator>, extra: ExtraArgs) => Promise<{
    ctx: CustomCtx;
    args: CustomMadeArgs;
    onSuccess?: (obj: {
      ctx: Ctx;
      args: Record<string, unknown>;
      result: unknown;
    }) => void | Promise<void>;
  }> | {
    ctx: CustomCtx;
    args: CustomMadeArgs;
    onSuccess?: (obj: {
      ctx: Ctx;
      args: Record<string, unknown>;
      result: unknown;
    }) => void | Promise<void>;
  };
};
/**
 * A Convex function (query, mutation, or action) to be registered for the API.
 * Convenience to specify the registration type based on function type.
 */
type Registration<FuncType extends 'query' | 'mutation' | 'action', Visibility extends FunctionVisibility, Args extends DefaultFunctionArgs, Output> = {
  query: RegisteredQuery<Visibility, Args, Output>;
  mutation: RegisteredMutation<Visibility, Args, Output>;
  action: RegisteredAction<Visibility, Args, Output>;
}[FuncType];
//#endregion
//#region src/internal/upstream/server/zod4.d.ts
/**
 * zCustomQuery is like customQuery, but allows validation via zod.
 * You can define custom behavior on top of `query` or `internalQuery`
 * by passing a function that modifies the ctx and args. Or NoOp to do nothing.
 *
 * Example usage:
 * ```ts
 * const myQueryBuilder = zCustomQuery(query, {
 *   args: { sessionId: v.id("sessions") },
 *   input: async (ctx, args) => {
 *     const user = await getUserOrNull(ctx);
 *     const session = await db.get(sessionId);
 *     const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
 *     return { ctx: { db, user, session }, args: {} };
 *   },
 * });
 *
 * // Using the custom builder
 * export const getSomeData = myQueryBuilder({
 *   args: { someArg: z.string() },
 *   handler: async (ctx, args) => {
 *     const { db, user, session, scheduler } = ctx;
 *     const { someArg } = args;
 *     // ...
 *   }
 * });
 * ```
 *
 * Simple usage only modifying ctx:
 * ```ts
 * const myInternalQuery = zCustomQuery(
 *   internalQuery,
 *   customCtx(async (ctx) => {
 *     return {
 *       // Throws an exception if the user isn't logged in
 *       user: await getUserByTokenIdentifier(ctx),
 *     };
 *   })
 * );
 *
 * // Using it
 * export const getUser = myInternalQuery({
 *   args: { email: z.string().email() },
 *   handler: async (ctx, args) => {
 *     console.log(args.email);
 *     return ctx.user;
 *   },
 * });
 *
 * @param query The query to be modified. Usually `query` or `internalQuery`
 *   from `_generated/server`.
 * @param customization The customization to be applied to the query, changing ctx and args.
 * @returns A new query builder using zod validation to define queries.
 */
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>;
/**
 * zCustomMutation is like customMutation, but allows validation via zod.
 * You can define custom behavior on top of `mutation` or `internalMutation`
 * by passing a function that modifies the ctx and args. Or NoOp to do nothing.
 *
 * Example usage:
 * ```ts
 * const myMutationBuilder = zCustomMutation(mutation, {
 *   args: { sessionId: v.id("sessions") },
 *   input: async (ctx, args) => {
 *     const user = await getUserOrNull(ctx);
 *     const session = await db.get(sessionId);
 *     const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
 *     return { ctx: { db, user, session }, args: {} };
 *   },
 * });
 *
 * // Using the custom builder
 * export const getSomeData = myMutationBuilder({
 *   args: { someArg: z.string() },
 *   handler: async (ctx, args) => {
 *     const { db, user, session, scheduler } = ctx;
 *     const { someArg } = args;
 *     // ...
 *   }
 * });
 * ```
 *
 * Simple usage only modifying ctx:
 * ```ts
 * const myInternalMutation = zCustomMutation(
 *   internalMutation,
 *   customCtx(async (ctx) => {
 *     return {
 *       // Throws an exception if the user isn't logged in
 *       user: await getUserByTokenIdentifier(ctx),
 *     };
 *   })
 * );
 *
 * // Using it
 * export const getUser = myInternalMutation({
 *   args: { email: z.string().email() },
 *   handler: async (ctx, args) => {
 *     console.log(args.email);
 *     return ctx.user;
 *   },
 * });
 *
 * @param mutation The mutation to be modified. Usually `mutation` or `internalMutation`
 *   from `_generated/server`.
 * @param customization The customization to be applied to the mutation, changing ctx and args.
 * @returns A new mutation builder using zod validation to define queries.
 */
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>;
/**
 * zCustomAction is like customAction, but allows validation via zod.
 * You can define custom behavior on top of `action` or `internalAction`
 * by passing a function that modifies the ctx and args. Or NoOp to do nothing.
 *
 * Example usage:
 * ```ts
 * const myActionBuilder = zCustomAction(action, {
 *   args: { sessionId: v.id("sessions") },
 *   input: async (ctx, args) => {
 *     const user = await getUserOrNull(ctx);
 *     const session = await db.get(sessionId);
 *     const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
 *     return { ctx: { db, user, session }, args: {} };
 *   },
 * });
 *
 * // Using the custom builder
 * export const getSomeData = myActionBuilder({
 *   args: { someArg: z.string() },
 *   handler: async (ctx, args) => {
 *     const { db, user, session, scheduler } = ctx;
 *     const { someArg } = args;
 *     // ...
 *   }
 * });
 * ```
 *
 * Simple usage only modifying ctx:
 * ```ts
 * const myInternalAction = zCustomAction(
 *   internalAction,
 *   customCtx(async (ctx) => {
 *     return {
 *       // Throws an exception if the user isn't logged in
 *       user: await getUserByTokenIdentifier(ctx),
 *     };
 *   })
 * );
 *
 * // Using it
 * export const getUser = myInternalAction({
 *   args: { email: z.string().email() },
 *   handler: async (ctx, args) => {
 *     console.log(args.email);
 *     return ctx.user;
 *   },
 * });
 *
 * @param action The action to be modified. Usually `action` or `internalAction`
 *   from `_generated/server`.
 * @param customization The customization to be applied to the action, changing ctx and args.
 * @returns A new action builder using zod validation to define queries.
 */
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>;
/**
 * Creates a validator for a Convex `Id`.
 *
 * - When **used within Zod**, it will only check that the ID is a string.
 * - When **converted to a Convex validator** (e.g. through {@link zodToConvex}),
 *   it will check that it's for the right table.
 *
 * @param tableName - The table that the `Id` references. i.e. `Id<tableName>`
 * @returns A Zod schema representing a Convex `Id`
 */
declare const zid: <DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel> = TableNamesInDataModel<DataModel>>(tableName: TableName) => Zid<TableName>;
/** The type of Convex validators in Zod */
type Zid<TableName extends string> = z$1.ZodCustom<GenericId<TableName>> & zCore.$ZodRecordKey;
/**
 * Useful to get the input context type for a custom function using Zod.
 */
type ZCustomCtx<Builder> = Builder extends CustomBuilder<any, any, infer CustomCtx, any, infer InputCtx, any, any> ? Overwrite<InputCtx, CustomCtx> : never;
/**
 * Turns a Zod or Zod Mini validator into a Convex validator.
 *
 * The Convex validator will be as close to possible to the Zod validator,
 * but might be broader than the Zod validator:
 *
 * ```ts
 * zodToConvex(z.string().email()) // → v.string()
 * ```
 *
 * This function is useful when running the Zod validator _after_ running the Convex validator
 * (i.e. the Convex validator validates the input of the Zod validator). Hence, the Convex types
 * will match the _input type_ of Zod transformations:
 * ```ts
 * zodToConvex(z.object({
 *   name: z.string().default("Nicolas"),
 * })) // → v.object({ name: v.optional(v.string()) })
 *
 * zodToConvex(z.object({
 *   name: z.string().transform(s => s.length)
 * })) // → v.object({ name: v.string() })
 * ````
 *
 * This function is useful for:
 * * **Validating function arguments with Zod**: through {@link zCustomQuery},
 *   {@link zCustomMutation} and {@link zCustomAction}, you can define the argument validation logic
 *   using Zod validators instead of Convex validators. `zodToConvex` will generate a Convex validator
 *   from your Zod validator. This will allow you to:
 *     - validate at run time that Convex IDs are from the right table (using {@link zid})
 *     - allow some features of Convex to understand the expected shape of the arguments
 *       (e.g. argument validation/prefilling in the function runner on the Convex dashboard)
 *     - still run the full Zod validation when the function runs
 *       (which is useful for more advanced Zod validators like `z.string().email()`)
 * * **Validating data after reading it from the database**: if you want to write your DB schema
 *   with Zod, you can run Zod whenever you read from the database to check that the data
 *   still matches the schema. Note that this approach won’t ensure that the data stored in the DB
 *   matches the Zod schema; see
 *   https://stack.convex.dev/typescript-zod-function-validation#can-i-use-zod-to-define-my-database-types-too
 *   for more details.
 *
 * Note that some values might be valid in Zod but not in Convex,
 * in the same way that valid JavaScript values might not be valid
 * Convex values for the corresponding Convex type.
 * (see the limits of Convex data types on https://docs.convex.dev/database/types).
 *
 * ```
 * ┌─────────────────────────────────────┬─────────────────────────────────────┐
 * │          **zodToConvex**            │          zodOutputToConvex          │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ For when the Zod validator runs     │ For when the Zod validator runs     │
 * │ _after_ the Convex validator        │ _before_ the Convex validator       │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ Convex types use the _input types_  │ Convex types use the _return types_ │
 * │ of Zod transformations              │ of Zod transformations              │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ The Convex validator can be less    │ The Convex validator can be less    │
 * │ strict (i.e. some inputs might be   │ strict (i.e. the type in Convex can │
 * │ accepted by Convex then rejected    │ be less precise than the type in    │
 * │ by Zod)                             │ the Zod output)                     │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ When using Zod schemas              │ When using Zod schemas              │
 * │ for function definitions:           │ for function definitions:           │
 * │ used for _arguments_                │ used for _return values_            │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ When validating contents of the     │ When validating contents of the     │
 * │ database with a Zod schema:         │ database with a Zod schema:         │
 * │ used to validate data               │ used to validate data               │
 * │ _after reading_                     │ _before writing_                    │
 * └─────────────────────────────────────┴─────────────────────────────────────┘
 * ```
 *
 * @param zod Zod validator can be a Zod object, or a Zod type like `z.string()`
 * @returns Convex Validator (e.g. `v.string()` from "convex/values")
 * @throws If there is no equivalent Convex validator for the value (e.g. `z.date()`)
 */
declare function zodToConvex<Z extends zCore.$ZodType>(validator: Z): ConvexValidatorFromZod<Z, 'required'>;
/**
 * Converts a Zod or Zod Mini validator to a Convex validator that checks the value _after_
 * it has been validated (and possibly transformed) by the Zod validator.
 *
 * This is similar to {@link zodToConvex}, but is meant for cases where the Convex
 * validator runs _after_ the Zod validator. Thus, the Convex type refers to the
 * _output_ type of the Zod transformations:
 * ```ts
 * zodOutputToConvex(z.object({
 *   name: z.string().default("Nicolas"),
 * })) // → v.object({ name: v.string() })
 *
 * zodOutputToConvex(z.object({
 *   name: z.string().transform(s => s.length)
 * })) // → v.object({ name: v.number() })
 * ````
 *
 * This function can be useful for:
 * - **Validating function return values with Zod**: through {@link zCustomQuery},
 *   {@link zCustomMutation} and {@link zCustomAction}, you can define the `returns` property
 *   of a function using Zod validators instead of Convex validators.
 * - **Validating data after reading it from the database**: if you want to write your DB schema
 *   Zod validators, you can run Zod whenever you write to the database to ensure your data matches
 *   the expected format. Note that this approach won’t ensure that the data stored in the DB
 *   isn’t modified manually in a way that doesn’t match your Zod schema; see
 *   https://stack.convex.dev/typescript-zod-function-validation#can-i-use-zod-to-define-my-database-types-too
 *   for more details.
 *
 * ```
 * ┌─────────────────────────────────────┬─────────────────────────────────────┐
 * │            zodToConvex              │        **zodOutputToConvex**        │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ For when the Zod validator runs     │ For when the Zod validator runs     │
 * │ _after_ the Convex validator        │ _before_ the Convex validator       │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ Convex types use the _input types_  │ Convex types use the _return types_ │
 * │ of Zod transformations              │ of Zod transformations              │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ The Convex validator can be less    │ The Convex validator can be less    │
 * │ strict (i.e. some inputs might be   │ strict (i.e. the type in Convex can │
 * │ accepted by Convex then rejected    │ be less precise than the type in    │
 * │ by Zod)                             │ the Zod output)                     │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ When using Zod schemas              │ When using Zod schemas              │
 * │ for function definitions:           │ for function definitions:           │
 * │ used for _arguments_                │ used for _return values_            │
 * ├─────────────────────────────────────┼─────────────────────────────────────┤
 * │ When validating contents of the     │ When validating contents of the     │
 * │ database with a Zod schema:         │ database with a Zod schema:         │
 * │ used to validate data               │ used to validate data               │
 * │ _after reading_                     │ _before writing_                    │
 * └─────────────────────────────────────┴─────────────────────────────────────┘
 * ```
 *
 * @param z The zod validator
 * @returns Convex Validator (e.g. `v.string()` from "convex/values")
 * @throws If there is no equivalent Convex validator for the value (e.g. `z.date()`)
 */
declare function zodOutputToConvex<Z extends zCore.$ZodType>(validator: Z): ConvexValidatorFromZodOutput<Z, 'required'>;
type ZodFields = Record<string, zCore.$ZodType>;
/**
 * Like {@link zodToConvex}, but it takes in a bare object, as expected by Convex
 * function arguments, or the argument to {@link defineTable}.
 *
 * ```ts
 * zodToConvexFields({
 *   name: z.string().default("Nicolas"),
 * }) // → { name: v.optional(v.string()) }
 * ```
 *
 * @param fields Object with string keys and Zod validators as values
 * @returns Object with the same keys, but with Convex validators as values
 */
declare function zodToConvexFields<Fields extends ZodFields>(fields: Fields): { [k in keyof Fields]: Fields[k] extends zCore.$ZodType ? ConvexValidatorFromZod<Fields[k], "required"> : never };
/**
 * Like {@link zodOutputToConvex}, but it takes in a bare object, as expected by
 * Convex function arguments, or the argument to {@link defineTable}.
 *
 * ```ts
 * zodOutputToConvexFields({
 *   name: z.string().default("Nicolas"),
 * }) // → { name: v.string() }
 * ```
 *
 * This is different from {@link zodToConvexFields} because it generates the
 * Convex validator for the output of the Zod validator, not the input;
 * see the documentation of {@link zodToConvex} and {@link zodOutputToConvex}
 * for more details.
 *
 * @param zod Object with string keys and Zod validators as values
 * @returns Object with the same keys, but with Convex validators as values
 */
declare function zodOutputToConvexFields<Fields extends ZodFields>(fields: Fields): { [k in keyof Fields]: ConvexValidatorFromZodOutput<Fields[k], "required"> };
/**
 * Turns a Convex validator into a Zod validator.
 *
 * This is useful when you want to use types you defined using Convex validators
 * with external libraries that expect to receive a Zod validator.
 *
 * ```ts
 * convexToZod(v.string()) // → z.string()
 * ```
 *
 * This function returns Zod validators, not Zod Mini validators.
 *
 * @param convexValidator Convex validator can be any validator from "convex/values" e.g. `v.string()`
 * @returns Zod validator (e.g. `z.string()`) with inferred type matching the Convex validator
 */
declare function convexToZod<V extends GenericValidator>(convexValidator: V): ZodValidatorFromConvex<V>;
/**
 * Like {@link convexToZod}, but it takes in a bare object, as expected by Convex
 * function arguments, or the argument to {@link defineTable}.
 *
 * ```ts
 * convexToZodFields({
 *   name: v.string(),
 * }) // → { name: z.string() }
 * ```
 *
 * @param convexValidators Object with string keys and Convex validators as values
 * @returns Object with the same keys, but with Zod validators as values
 */
declare function convexToZodFields<C extends PropertyValidators>(convexValidators: C): { [k in keyof C]: ZodValidatorFromConvex<C[k]> };
/**
 * Zod helper for adding Convex system fields to a record to return.
 *
 * ```ts
 * withSystemFields("users", {
 *   name: z.string(),
 * })
 * // → {
 * //   name: z.string(),
 * //   _id: zid("users"),
 * //   _creationTime: z.number(),
 * // }
 * ```
 *
 * @param tableName - The table where records are from, i.e. Doc<tableName>
 * @param zObject - Validators for the user-defined fields on the document.
 * @returns Zod shape for use with `z.object(shape)` that includes system fields.
 */
declare function withSystemFields<Table extends string, T extends {
  [key: string]: zCore.$ZodType;
}>(tableName: Table, zObject: T): T & {
  _id: Zid<Table>;
  _creationTime: z$1.ZodNumber;
};
/**
 * A builder that customizes a Convex function, whether or not it validates
 * arguments. If the customization requires arguments, however, the resulting
 * builder will require argument validation too.
 */
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: ({
  /**
   * Specify the arguments to the function as a Zod validator.
   */
  args?: ArgsValidator;
  handler: (ctx: Overwrite<InputCtx, CustomCtx>, ...args: ArgsForHandlerType<ArgsOutput<ArgsValidator>, CustomMadeArgs>) => ReturnValue;
  /**
   * Validates the value returned by the function.
   * Note: you can't pass an object directly without wrapping it
   * in `z.object()`.
   */
  returns?: ReturnsZodValidator;
  /**
   * If true, the function will not be validated by Convex,
   * in case you're seeing performance issues with validating twice.
   */
  skipConvexValidation?: boolean;
} & { [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>>;
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];
type NullToUndefinedOrNull<T> = T extends null ? T | undefined | void : T;
type Returns<T> = Promise<NullToUndefinedOrNull<T>> | NullToUndefinedOrNull<T>;
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;
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;
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;
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;
type Overwrite<T, U> = Omit<T, keyof U> & U;
type OneArgArray<ArgsObject extends DefaultFunctionArgs = DefaultFunctionArgs> = [ArgsObject];
/**
 * Return type of {@link zodToConvex}.
 */
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>;
/**
 * Return type of {@link zodOutputToConvex}.
 */
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>;
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;
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']>;
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>[];
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;
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>;
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] }>;
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>;
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;
type IsUnion<T, U extends T = T> = T extends unknown ? [U] extends [T] ? false : true : false;
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>;
type IsUnknownOrAny<T> = 0 extends 1 & T ? true : unknown extends T ? true : false;
/**
 * Better type conversion from a Convex validator to a Zod validator
 * where the output is not a generic ZodType but it's more specific.
 *
 * This allows you to use methods specific to the Zod type (e.g. `.email()` for `z.ZodString`).
 *
 * ```ts
 * ZodValidatorFromConvex<typeof v.string()> // → z.ZodString
 * ```
 */
type ZodValidatorFromConvex<V extends GenericValidator> = V extends Validator<any, 'optional', any> ? z$1.ZodOptional<ZodFromValidatorBase<VRequired<V>>> : ZodFromValidatorBase<V>;
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;
type BrandIfBranded<InnerType, Validator extends zCore.SomeType> = InnerType extends zCore.$brand<infer Brand> ? zCore.$ZodBranded<Validator, Brand> : Validator;
type StringValidator = Validator<string, 'required', any>;
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;
type ZodShapeFromConvexObject<Fields extends Record<string, GenericValidator>> = Fields extends infer F ? { [K in keyof F]: F[K] extends GenericValidator ? ZodValidatorFromConvex<F[K]> : never } : never;
type NotUndefined<T> = Exclude<T, undefined>;
type TableNameFromType<T> = T extends GenericId<infer TableName> ? TableName : string;
//#endregion
//#region src/server/http-builder.d.ts
declare function extractPathParams(path: string): string[];
declare function matchPathParams(template: string, pathname: string): Record<string, string> | null;
declare function handleHttpError(error: unknown): Response;
/**
 * HttpProcedureBuilder - Fluent builder for HTTP endpoints
 *
 * Uses tRPC-style interface + factory pattern for proper generic type preservation:
 * - Interface declares full generics with explicit return types
 * - Factory function creates implementation objects
 * - This preserves literal types like 'GET' through method chains
 */
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> {
  _def: HttpProcedureBuilderDef<TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
  /** DELETE endpoint (Hono-style) */
  delete(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'DELETE', TForm>;
  /** Define form data schema (for multipart/form-data uploads) */
  form<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TSchema>;
  /** GET endpoint (Hono-style) */
  get(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'GET', TForm>;
  /** Define request body schema (for POST/PUT/PATCH) */
  input<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TSchema, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
  /** Set procedure metadata (shallow merged when chained) */
  meta(value: TMeta): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
  /**
   * Define the handler for POST/PUT/PATCH/DELETE endpoints (maps to useMutation on client).
   * Handler receives Hono Context `c` for Response helpers (c.json, c.body, c.text).
   * Return Response for custom responses, or plain object for auto JSON serialization.
   */
  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>;
  /** Set a server-only procedure name for middleware/logging */
  name(value: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
  /** Define response schema */
  output<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TSchema, TParams, TQuery, TMeta, TMethod, TForm>;
  /** Define path parameter schema (for :param in path) */
  params<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TSchema, TQuery, TMeta, TMethod, TForm>;
  /** PATCH endpoint (Hono-style) */
  patch(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PATCH', TForm>;
  /** POST endpoint (Hono-style) */
  post(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'POST', TForm>;
  /** PUT endpoint (Hono-style) */
  put(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PUT', TForm>;
  /**
   * Define the handler for GET endpoints (maps to useQuery on client).
   * Handler receives Hono Context `c` for Response helpers (c.json, c.body, c.text).
   * Return Response for custom responses, or plain object for auto JSON serialization.
   */
  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>;
  /** Define the route path and HTTP method */
  route<M extends HttpMethod>(path: string, method: M): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, M, TForm>;
  /** Define query parameter schema (?key=value) */
  searchParams<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TSchema, TMeta, TMethod, TForm>;
  /** Add middleware to the procedure */
  use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<TCtx, TMeta, UnsetMarker, $ContextOverridesOut, unknown> | MiddlewareBuilder<any, // Allow reusable middleware with any context
  TMeta, $ContextOverridesOut, unknown>): HttpProcedureBuilder<TInitialCtx, Overwrite$1<TCtx, $ContextOverridesOut>, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
}
/**
 * Create initial HttpProcedureBuilder
 */
declare function createHttpProcedureBuilder<TCtx, TMeta extends ProcedureMeta>(config: {
  base: HttpProcedureBuilderDef<TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod, UnsetMarker>['functionConfig']['base'];
  createContext: (ctx: GenericActionCtx<GenericDataModel>) => TCtx;
  meta: TMeta;
  transformer?: DataTransformerOptions;
}): HttpProcedureBuilder<TCtx, TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod, UnsetMarker>;
//#endregion
//#region src/server/builder.d.ts
/**
 * Paginated schema for type inference ONLY.
 * After .paginated() applies defaults, cursor and limit are always defined.
 * The actual runtime schema uses .default() and .transform() for validation.
 */
declare const paginatedSchemaForTypes: z.ZodObject<{
  cursor: z.ZodUnion<readonly [z.ZodString, z.ZodNull]>;
  limit: z.ZodNumber;
}, z.core.$strip>;
/** Paginated schema type - both cursor and limit are required after .paginated() */
type PaginatedInputSchema = typeof paginatedSchemaForTypes;
/** Paginated schema type for external callers - both fields are optional due defaults. */
declare const paginatedSchemaForClientTypes: z.ZodObject<{
  cursor: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
  limit: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
type PaginatedClientInputSchema = typeof paginatedSchemaForClientTypes;
/**
 * Infer input type from ZodObject schema (for handlers)
 */
type InferInput<T> = T extends UnsetMarker ? Record<string, never> : T extends z.ZodObject<any> ? z.infer<T> : never;
/**
 * Infer raw client input before defaults/transforms.
 * Used for generated API arg typing.
 */
type InferClientInput<T> = T extends UnsetMarker ? Record<string, never> : T extends z.ZodObject<any> ? z.input<T> : never;
/**
 * Infer input type for middleware (returns unknown for UnsetMarker, matching tRPC)
 * Middleware before .input() receives unknown input
 */
type InferMiddlewareInput<T> = T extends UnsetMarker ? unknown : T extends z.ZodObject<any> ? z.infer<T> : unknown;
/**
 * Static-only type hint attached to cRPC exports.
 *
 * Convex validators can widen unsupported types (like Date) to `any`.
 * Codegen can read this hint from `typeof import(...).fn` to recover precise
 * TypeScript input/output types for generated client API refs.
 */
type CRPCFunctionTypeHint<TArgs, TReturns> = {
  readonly __kitcnTypeHint?: {
    readonly args: TArgs;
    readonly returns: TReturns;
  };
};
/** Base config shape for function builders */
type FunctionBuilderConfig = {
  /** Base function builder (query, mutation, or action from Convex) */base: unknown; /** Internal function builder (internalQuery, etc.) */
  internal?: unknown;
};
/** Internal config combining context creator with function builders */
type InternalFunctionConfig = FunctionBuilderConfig & {
  /** Transform raw Convex context to the base context for procedures */createContext: (ctx: any) => unknown; /** Wire transformer for request/response serialization. */
  transformer: ReturnType<typeof getTransformer>;
};
/** Context creators for each function type - all optional, defaults to passthrough */
type ContextConfig<DataModel extends GenericDataModel> = {
  query?: (ctx: GenericQueryCtx<DataModel>) => unknown;
  mutation?: (ctx: GenericMutationCtx<DataModel>) => unknown;
  action?: (ctx: GenericActionCtx<DataModel>) => unknown;
};
/** Infer context types from config - defaults to raw Convex ctx when not specified */
type InferQueryCtx<T, DataModel extends GenericDataModel> = T extends {
  query: (...args: never[]) => infer R;
} ? R : GenericQueryCtx<DataModel>;
type InferMutationCtx<T, DataModel extends GenericDataModel> = T extends {
  mutation: (...args: never[]) => infer R;
} ? R : GenericMutationCtx<DataModel>;
type InferActionCtx<T, DataModel extends GenericDataModel> = T extends {
  action: (...args: never[]) => infer R;
} ? R : GenericActionCtx<DataModel>;
/** Function builders for each function type */
type FunctionsConfig = {
  query?: unknown;
  internalQuery?: unknown;
  mutation?: unknown;
  internalMutation?: unknown;
  action?: unknown;
  internalAction?: unknown;
  httpAction?: unknown;
};
/** Config for create() including optional defaultMeta */
type CreateConfig<TMeta extends object> = FunctionsConfig & {
  defaultMeta?: TMeta; /** Optional cRPC payload transformer (always composed with built-in Date support). */
  transformer?: DataTransformerOptions;
};
/**
 * Create a middleware factory for building reusable middleware chains
 *
 * @example
 * ```typescript
 * const loggedIn = c.middleware(({ ctx, next }) => {
 *   if (!ctx.userId) throw new CRPCError({ code: 'UNAUTHORIZED' });
 *   return next({ ctx });
 * });
 *
 * const isAdmin = loggedIn.pipe(({ ctx, next }) => {
 *   if (!ctx.user.isAdmin) throw new CRPCError({ code: 'FORBIDDEN' });
 *   return next({ ctx });
 * });
 * ```
 */
declare function createMiddlewareFactory<TDefaultContext, TMeta = object>(): <TContext = TDefaultContext, $ContextOverridesOut = object>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverridesOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverridesOut, unknown>;
/** Internal definition storing procedure state */
type ProcedureBuilderDef<TMeta = object> = {
  middlewares: AnyMiddleware[];
  inputSchemas: Record<string, any>[];
  outputSchema?: z.ZodTypeAny;
  meta?: TMeta;
  procedureName?: string;
  functionConfig: InternalFunctionConfig; /** Whether this procedure uses internal function (not exposed to clients) */
  isInternal?: boolean;
};
/**
 * Fluent procedure builder with full type inference
 *
 * @typeParam TBaseCtx - Base context type from config
 * @typeParam TContext - Current context type (starts as TBaseCtx)
 * @typeParam TContextOverrides - Accumulated context from middleware (starts as UnsetMarker)
 * @typeParam TInput - Input schema (starts as UnsetMarker)
 * @typeParam TOutput - Output schema (starts as UnsetMarker)
 * @typeParam TMeta - Procedure metadata type
 */
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> {
  protected readonly _def: ProcedureBuilderDef<TMeta>;
  constructor(def: ProcedureBuilderDef<TMeta>);
  /** Add middleware that transforms the context - to be overridden by subclasses */
  protected _use<$ContextOverridesOut>(middlewareOrBuilder: MiddlewareFunction<TBaseCtx, TMeta, TContextOverrides, $ContextOverridesOut> | MiddlewareBuilder<TBaseCtx, TMeta, $ContextOverridesOut>): ProcedureBuilderDef<TMeta>;
  /** Define input schema (chainable - schemas are merged) - to be overridden by subclasses */
  protected _input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): ProcedureBuilderDef<TMeta>;
  /** Define output schema - to be overridden by subclasses */
  protected _output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): ProcedureBuilderDef<TMeta>;
  /** Set procedure metadata (shallow merged when chained) - to be overridden by subclasses */
  protected _meta(value: TMeta): ProcedureBuilderDef<TMeta>;
  /** Set server-only procedure name for middleware/logging */
  protected _name(value: string): ProcedureBuilderDef<TMeta>;
  /** Merge all input schemas into one */
  protected _getMergedInput(): Record<string, any> | undefined;
  protected _createFunction(handler: any, baseFunction: any, customFn: typeof zCustomQuery | typeof zCustomMutation | typeof zCustomAction, fnType: 'query' | 'mutation' | 'action'): Record<string, unknown>;
}
/**
 * Query-specific procedure builder
 * Only exposes .query() and .internalQuery() methods
 */
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> {
  /**
   * Add middleware that transforms the context
   * Middleware receives typed input if called after .input(), unknown otherwise
   * $ContextOverridesOut is inferred from next()
   */
  use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite$1<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<any, // Allow reusable middleware with any context
  TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): QueryProcedureBuilder<TBaseCtx, TContext, Overwrite$1<TContextOverrides, $ContextOverridesOut>, TInput, TClientInput, TOutput, TMeta>;
  /** Set procedure metadata (shallow merged when chained) */
  meta(value: TMeta): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TOutput, TMeta>;
  /** Set a server-only procedure name for middleware/logging */
  name(value: string): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TOutput, TMeta>;
  /** Define input schema (chainable - schemas are merged) */
  input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, TNewInput>, IntersectIfDefined<TClientInput, TNewInput>, TOutput, TMeta>;
  /**
   * Add pagination input (chainable before .query())
   *
   * Creates flat { cursor, limit } input like tRPC and auto-wraps output.
   * User accesses args.cursor and args.limit directly.
   *
   * @param opts.limit - Default/max items per page
   * @param opts.item - Zod schema for each item in the page array
   */
  paginated<TItem extends z.ZodTypeAny>(opts: {
    limit: number;
    item: TItem;
  }): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, PaginatedInputSchema>, IntersectIfDefined<TClientInput, PaginatedClientInputSchema>, z.ZodObject<{
    continueCursor: z.ZodUnion<[z.ZodString, z.ZodNull]>;
    isDone: z.ZodBoolean;
    page: z.ZodArray<TItem>;
  }>, TMeta>;
  /** Define output schema */
  output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TNewOutput, TMeta>;
  /** Create a query */
  query<TResult>(handler: (opts: {
    ctx: Overwrite$1<TContext, TContextOverrides>;
    input: InferInput<TInput>;
  }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): Record<string, unknown> & CRPCFunctionTypeHint<InferClientInput<TClientInput>, TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>;
  /** Mark as internal - returns chainable builder using internal function */
  internal(): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TClientInput, TOutput, TMeta>;
}
/**
 * Mutation-specific procedure builder
 * Only exposes .mutation() and .internalMutation() methods
 */
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> {
  /**
   * Add middleware that transforms the context
   * Middleware receives typed input if called after .input(), unknown otherwise
   * $ContextOverridesOut is inferred from next()
   */
  use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite$1<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<any, // Allow reusable middleware with any context
  TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): MutationProcedureBuilder<TBaseCtx, TContext, Overwrite$1<TContextOverrides, $ContextOverridesOut>, TInput, TOutput, TMeta>;
  /** Set procedure metadata (shallow merged when chained) */
  meta(value: TMeta): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
  /** Set a server-only procedure name for middleware/logging */
  name(value: string): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
  /** Define input schema (chainable - schemas are merged) */
  input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, TNewInput>, TOutput, TMeta>;
  /** Define output schema */
  output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TNewOutput, TMeta>;
  /** Create a mutation */
  mutation<TResult>(handler: (opts: {
    ctx: Overwrite$1<TContext, TContextOverrides>;
    input: InferInput<TInput>;
  }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): Record<string, unknown> & CRPCFunctionTypeHint<InferClientInput<TInput>, TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>;
  /** Mark as internal - returns chainable builder using internal function */
  internal(): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
}
/**
 * Action-specific procedure builder
 * Only exposes .action() and .internalAction() methods
 */
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> {
  /** Add middleware that transforms the context - $ContextOverridesOut is inferred from next() */
  use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite$1<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<any, // Allow reusable middleware with any context
  TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): ActionProcedureBuilder<TBaseCtx, TContext, Overwrite$1<TContextOverrides, $ContextOverridesOut>, TInput, TOutput, TMeta>;
  /** Set procedure metadata (shallow merged when chained) */
  meta(value: TMeta): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
  /** Set a server-only procedure name for middleware/logging */
  name(value: string): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
  /** Define input schema (chainable - schemas are merged) */
  input<TNewInput extends z.ZodObject<any>>(schema: TNewInput): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, IntersectIfDefined<TInput, TNewInput>, TOutput, TMeta>;
  /** Define output schema */
  output<TNewOutput extends z.ZodTypeAny>(schema: TNewOutput): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TNewOutput, TMeta>;
  /** Create an action */
  action<TResult>(handler: (opts: {
    ctx: Overwrite$1<TContext, TContextOverrides>;
    input: InferInput<TInput>;
  }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): Record<string, unknown> & CRPCFunctionTypeHint<InferClientInput<TInput>, TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>;
  /** Mark as internal - returns chainable builder using internal function */
  internal(): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
}
/** Return type for create() */
type CRPCInstance<_DataModel extends GenericDataModel, TQueryCtx, TMutationCtx, TActionCtx, THttpActionCtx, TMeta extends object = object> = {
  query: QueryProcedureBuilder<TQueryCtx, TQueryCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta>;
  mutation: MutationProcedureBuilder<TMutationCtx, TMutationCtx, UnsetMarker, UnsetMarker, UnsetMarker, TMeta>;
  action: ActionProcedureBuilder<TActionCtx, TActionCtx, UnsetMarker, UnsetMarker, UnsetMarker, TMeta>;
  httpAction: HttpProcedureBuilder<THttpActionCtx, THttpActionCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod>; /** Create reusable middleware - defaults to query context, override with generic */
  middleware: <TContext = TQueryCtx, $ContextOverridesOut = object>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverridesOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverridesOut>; /** Create HTTP router (like tRPC's t.router) */
  router: <TRecord extends HttpRouterRecord>(record: TRecord) => CRPCHttpRouter<TRecord>;
};
/**
 * Builder with context configured, ready to create instance
 */
declare class CRPCBuilderWithContext<DataModel extends GenericDataModel, TQueryCtx, TMutationCtx, TActionCtx = GenericActionCtx<DataModel>, THttpActionCtx = GenericActionCtx<DataModel>, TMeta extends object = object> {
  private readonly contextConfig;
  constructor(contextConfig: ContextConfig<DataModel>);
  /**
   * Define the metadata type for procedures (can be called after context)
   */
  meta<TNewMeta extends object>(): CRPCBuilderWithContext<DataModel, TQueryCtx, TMutationCtx, TActionCtx, THttpActionCtx, TNewMeta>;
  /**
   * Create the CRPC instance with function builders
   */
  create(config?: CreateConfig<TMeta>): CRPCInstance<DataModel, TQueryCtx, TMutationCtx, TActionCtx, THttpActionCtx, TMeta>;
}
/**
 * Builder with meta type configured
 */
declare class CRPCBuilderWithMeta<DataModel extends GenericDataModel, TMeta extends object = object> {
  /**
   * Configure context creators for each function type
   */
  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
  TMeta>;
  /**
   * Create the CRPC instance directly (uses default passthrough context)
   */
  create(config?: CreateConfig<TMeta>): CRPCInstance<DataModel, GenericQueryCtx<DataModel>, GenericMutationCtx<DataModel>, GenericActionCtx<DataModel>, GenericActionCtx<DataModel>, // httpAction uses action context
  TMeta>;
}
/**
 * Initial CRPC builder - configure meta and context
 */
declare class CRPCBuilder<DataModel extends GenericDataModel> {
  /**
   * Define the metadata type for procedures
   */
  meta<TMeta extends object>(): CRPCBuilderWithMeta<DataModel, TMeta>;
  /**
   * Configure context creators for each function type
   */
  context<TConfig extends ContextConfig<DataModel>>(config: TConfig): CRPCBuilderWithContext<DataModel, InferQueryCtx<TConfig, DataModel>, InferMutationCtx<TConfig, DataModel>, InferActionCtx<TConfig, DataModel>, InferActionCtx<TConfig, DataModel>>;
  /**
   * Create the CRPC instance directly (uses default passthrough context)
   */
  create(config?: CreateConfig<object>): CRPCInstance<DataModel, GenericQueryCtx<DataModel>, GenericMutationCtx<DataModel>, GenericActionCtx<DataModel>, GenericActionCtx<DataModel>, // httpAction uses action context
  object>;
}
/**
 * CRPC entry point - tRPC-style object
 *
 * @example
 * ```typescript
 * // With explicit DataModel type
 * const c = initCRPC
 *   .dataModel<DataModel>()
 *   .context({...})
 *   .create();
 *
 * // Without DataModel (uses GenericDataModel)
 * const c = initCRPC
 *   .context({...})
 *   .create();
 * ```
 */
declare const initCRPC: {
  /**
   * Set the DataModel type for the CRPC instance
   */
  dataModel<DataModel extends GenericDataModel>(): CRPCBuilder<DataModel>;
  /**
   * Define the metadata type (uses GenericDataModel)
   */
  meta<TMeta extends object>(): CRPCBuilderWithMeta<GenericDataModel, TMeta>;
  /**
   * Configure context creators (uses GenericDataModel)
   */
  context<TConfig extends ContextConfig<GenericDataModel>>(config: TConfig): CRPCBuilderWithContext<GenericDataModel, InferQueryCtx<TConfig, GenericDataModel>, InferMutationCtx<TConfig, GenericDataModel>, InferActionCtx<TConfig, GenericDataModel>, InferActionCtx<TConfig, GenericDataModel>>;
  /**
   * Create the CRPC instance directly (uses GenericDataModel and default passthrough context)
   */
  create(config?: CreateConfig<object>): CRPCInstance<GenericDataModel, GenericQueryCtx<GenericDataModel>, GenericMutationCtx<GenericDataModel>, GenericActionCtx<GenericDataModel>, GenericActionCtx<GenericDataModel>, // httpAction uses action context
  object>;
};
//#endregion
//#region src/server/api-entry.d.ts
type ApiFunctionType = 'query' | 'mutation' | 'action';
type GeneratedFunctionVisibility = 'public' | 'internal';
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;
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;
type CoerceArgs<TArgs> = TArgs extends DefaultFunctionArgs ? TArgs : TArgs extends Record<string, any> ? TArgs : Record<string, never>;
type ApiFunctionRefFromExport<TType extends ApiFunctionType, TExport> = FunctionReference<TType, 'public', CoerceArgs<InferArgsFromExport<TExport>>, InferReturnFromExport<TExport>>;
type GeneratedFunctionRefFromExport<TType extends ApiFunctionType, TVisibility extends GeneratedFunctionVisibility, TExport> = FunctionReference<TType, TVisibility, CoerceArgs<InferArgsFromExport<TExport>>, InferReturnFromExport<TExport>>;
type ApiFunctionLeafMeta = {
  type: ApiFunctionType;
  auth?: 'required' | 'optional';
  [key: string]: unknown;
};
type CreateApiLeafArgs<TMeta extends ApiFunctionLeafMeta> = [fn: unknown, meta: TMeta] | [root: unknown, path: readonly string[], meta: TMeta];
declare function getGeneratedValue<TValue = unknown>(root: unknown, path: readonly string[]): TValue;
/**
 * Build a generated API leaf from a Convex FunctionReference name.
 * Returns a plain FunctionReference-compatible object with attached cRPC metadata.
 */
declare function createApiLeaf<TType extends ApiFunctionType, TExport, TMeta extends ApiFunctionLeafMeta = ApiFunctionLeafMeta>(...args: CreateApiLeafArgs<TMeta>): ApiFunctionRefFromExport<TType, TExport> & TMeta & {
  functionRef: ApiFunctionRefFromExport<TType, TExport>;
};
declare function createGeneratedFunctionReference<TType extends ApiFunctionType, TVisibility extends GeneratedFunctionVisibility, TExport>(name: string): GeneratedFunctionRefFromExport<TType, TVisibility, TExport>;
//#endregion
//#region src/server/caller.d.ts
/** Metadata for a single function */
type FnMeta = {
  type?: 'query' | 'mutation' | 'action';
  [key: string]: unknown;
};
/** Metadata for all functions in a module */
type ModuleMeta = Record<string, FnMeta>;
/** Metadata for all modules - from generated `@convex/api` */
type CallerMeta = Record<string, ModuleMeta>;
/** Options for individual caller function calls */
type CallerOpts = {
  /** Skip query silently when unauthenticated (returns null instead of throwing) */skipUnauth?: boolean;
};
type CallerReturn<T, Opts extends CallerOpts | undefined> = Opts extends {
  skipUnauth: true;
} ? T | null : T;
type FetchFn<T extends 'query' | 'mutation' | 'action'> = <Fn extends FunctionReference<T>>(fn: Fn, args: Fn['_args'], opts?: CallerOpts) => Promise<FunctionReturnType<Fn> | null>;
type CreateCallerOptions = {
  fetchQuery: FetchFn<'query'>;
  fetchMutation: FetchFn<'mutation'>;
  fetchAction: FetchFn<'action'>;
  meta: CallerMeta;
  transformer?: DataTransformerOptions;
};
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]>;
type ServerCaller<TApi> = { [K in keyof TApi as K extends string ? K extends `_${string}` ? never : K extends 'http' ? never : K : K]: ServerCallerFn<TApi, K> };
/**
 * Create a server caller for direct data fetching without React Query.
 *
 * This is detached from React Query cache - data is NOT available in client components.
 * Use for server-only data that doesn't need to be shared with the client.
 *
 * @example
 * ```tsx
 * // src/lib/convex/rsc.tsx
 * export const caller = createServerCaller(api, {
 *   fetchQuery: fetchAuthQuery,
 *   fetchMutation: fetchAuthMutation,
 * });
 *
 * // app/page.tsx (RSC)
 * const posts = await caller.posts.list();
 * return <div>{posts?.length} posts</div>;
 * ```
 */
declare function createServerCaller<TApi extends Record<string, unknown>>(api: TApi, opts: CreateCallerOptions): ServerCaller<TApi>;
//#endregion
//#region src/server/lazy-caller.d.ts
type CallerContext<TApi> = {
  caller: ServerCaller<TApi>;
  token: string | undefined;
  isAuthenticated: boolean;
};
/**
 * Lazy caller with auth helper methods.
 * Context is created on first procedure invocation, not at definition time.
 */
type LazyCaller<TApi> = ServerCaller<TApi> & {
  /** Check if user is authenticated */isAuth: () => Promise<boolean>; /** Check if user is unauthenticated */
  isUnauth: () => Promise<boolean>; /** Get the auth token (for RSC prefetching) */
  getToken: () => Promise<string | undefined>;
};
/**
 * Create a lazy caller that creates context on each procedure invocation.
 * Matches tRPC's `appRouter.createCaller(createTRPCContext)` pattern.
 *
 * @example
 * ```ts
 * // server.ts
 * const { createContext, createCaller } = createCallerFactory({...});
 *
 * // rsc.tsx
 * const createRSCContext = cache(async () => {
 *   const heads = await headers();
 *   return createContext({ headers: heads });
 * });
 * export const caller = createCaller(createRSCContext);
 *
 * // app/page.tsx - single call! Context created lazily
 * const posts = await caller.posts.list();
 * ```
 */
declare function createLazyCaller<TApi extends Record<string, unknown>>(api: TApi, createContext: () => Promise<CallerContext<TApi>>): LazyCaller<TApi>;
//#endregion
//#region src/server/caller-factory.d.ts
type TokenResult = {
  token?: string;
  isFresh?: boolean;
};
type GetTokenFn = (siteUrl: string, headers: Headers, opts?: unknown) => Promise<TokenResult>;
/** Auth options for server-side calls. */
type AuthOptions = {
  /** Function to extract auth token from request headers. */getToken: GetTokenFn; /** Custom function to detect UNAUTHORIZED errors. Default checks code property. */
  isUnauthorized?: (error: unknown) => boolean;
};
type CreateCallerFactoryOptions<TApi> = {
  /** Your Convex API object. */api: TApi; /** Convex site URL (must end in `.convex.site`). */
  convexSiteUrl: string;
  /**
   * Convex deployment URL (must end in `.convex.cloud`).
   * Defaults to `convexSiteUrl` with the domain swapped.
   */
  convexUrl?: string; /** Auth options. Pass to enable authenticated calls with JWT caching. */
  auth?: AuthOptions; /** Optional wire transformer for request/response payloads (always composed with Date). */
  transformer?: DataTransformerOptions;
};
type ConvexContext<TApi> = {
  token: string | undefined;
  isAuthenticated: boolean;
  caller: ServerCaller<TApi>;
};
declare function createCallerFactory<TApi extends Record<string, unknown>>(opts: CreateCallerFactoryOptions<TApi>): {
  createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
  createContext: (reqOpts: {
    headers: Headers;
  }) => Promise<ConvexContext<TApi>>;
};
//#endregion
//#region src/server/env.d.ts
type RuntimeEnv = Record<string, string | undefined>;
type CreateEnvOptions<TSchema extends z.ZodObject<z.ZodRawShape>> = {
  cache?: boolean;
  codegenFallback?: boolean;
  runtimeEnv?: RuntimeEnv;
  schema: TSchema;
};
declare function createEnv<TSchema extends z.ZodObject<z.ZodRawShape>>(options: CreateEnvOptions<TSchema>): () => z.infer<TSchema>;
//#endregion
//#region src/server/error.d.ts
/** JSON-RPC 2.0 error codes (tRPC-style) */
declare const CRPC_ERROR_CODES_BY_KEY: {
  readonly PARSE_ERROR: -32700;
  readonly BAD_REQUEST: -32600;
  readonly INTERNAL_SERVER_ERROR: -32603;
  readonly NOT_IMPLEMENTED: -32603;
  readonly BAD_GATEWAY: -32603;
  readonly SERVICE_UNAVAILABLE: -32603;
  readonly GATEWAY_TIMEOUT: -32603;
  readonly UNAUTHORIZED: -32001;
  readonly PAYMENT_REQUIRED: -32002;
  readonly FORBIDDEN: -32003;
  readonly NOT_FOUND: -32004;
  readonly METHOD_NOT_SUPPORTED: -32005;
  readonly TIMEOUT: -32008;
  readonly CONFLICT: -32009;
  readonly PRECONDITION_FAILED: -32012;
  readonly PAYLOAD_TOO_LARGE: -32013;
  readonly UNSUPPORTED_MEDIA_TYPE: -32015;
  readonly UNPROCESSABLE_CONTENT: -32022;
  readonly PRECONDITION_REQUIRED: -32028;
  readonly TOO_MANY_REQUESTS: -32029;
  readonly CLIENT_CLOSED_REQUEST: -32099;
};
type CRPCErrorCode = keyof typeof CRPC_ERROR_CODES_BY_KEY;
/** Map error codes to HTTP status codes */
declare const CRPC_ERROR_CODE_TO_HTTP: Record<CRPCErrorCode, number>;
type CRPCErrorBaseData = {
  code: CRPCErrorCode;
  message: string;
};
type CRPCErrorData<TData extends Record<string, Value$1 | undefined> = Record<string, never>> = CRPCErrorBaseData & TData;
/**
 * tRPC-style error extending ConvexError
 *
 * @example
 * ```typescript
 * throw new CRPCError({
 *   code: 'BAD_REQUEST',
 *   message: 'Invalid input',
 *   cause: originalError,
 * });
 * ```
 */
declare class CRPCError<TData extends Record<string, Value$1 | undefined> = Record<string, never>> extends ConvexError<CRPCErrorData<TData>> {
  readonly code: CRPCErrorCode;
  readonly cause?: Error;
  constructor(opts: {
    code: CRPCErrorCode;
    message?: string;
    cause?: unknown;
    data?: TData;
  });
}
/**
 * Convert known framework/library errors into CRPCError.
 *
 * Intended for cRPC internals so callers don't need per-endpoint try/catch.
 */
declare function toCRPCError(cause: unknown): CRPCError | null;
/**
 * Wrap unknown error in CRPCError (from tRPC)
 *
 * @example
 * ```typescript
 * try {
 *   await someOperation();
 * } catch (error) {
 *   throw getCRPCErrorFromUnknown(error);
 * }
 * ```
 */
declare function getCRPCErrorFromUnknown(cause: unknown): CRPCError;
/**
 * Get HTTP status code from CRPCError
 *
 * @example
 * ```typescript
 * const httpStatus = getHTTPStatusCodeFromError(error); // 400
 * ```
 */
declare function getHTTPStatusCodeFromError(error: CRPCError): number;
/** Type guard for CRPCError */
declare function isCRPCError(error: unknown): error is CRPCError;
//#endregion
//#region src/server/infer.d.ts
/**
 * Combine a Convex API with an HTTP router for unified type inference.
 *
 * @example
 * ```ts
 * import type { WithHttpRouter } from 'kitcn/server';
 *
 * export type AppRouter = WithHttpRouter<typeof api, typeof httpRouter>;
 * export type ApiInputs = inferApiInputs<AppRouter>;
 * // ApiInputs['http']['todos']['create'] works
 * ```
 */
type WithHttpRouter<TApi, TRouter> = TApi & {
  http?: TRouter;
};
/** Helper to unwrap optional/nullable types for inference */
type UnwrapOptional<T> = T extends undefined ? never : NonNullable<T>;
type PublicApiKey<K> = K extends string ? K extends `_${string}` ? never : K : K;
/** Recursive output inference that handles optional properties */
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>;
/**
 * Infer all output types from a Convex API (including HTTP routes).
 * Optional properties (like `http?`) are unwrapped for easier access.
 *
 * @example
 * ```ts
 * import { api } from '@convex/api';
 * import type { inferApiOutputs } from 'kitcn/server';
 *
 * type AppRouter = typeof api & { http?: typeof httpRouter };
 * type ApiOutputs = inferApiOutputs<AppRouter>;
 *
 * type LinkData = ApiOutputs['scraper']['scrapeLink'];
 * type TodoList = ApiOutputs['http']['todos']['list'];
 * ```
 */
type inferApiOutputs<TApi> = { [K in keyof TApi as PublicApiKey<K>]-?: InferOutputsRecursive<UnwrapOptional<TApi[K]>> };
/** Recursive input inference that handles optional properties */
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>;
/**
 * Infer all input types from a Convex API (including HTTP routes).
 * Optional properties (like `http?`) are unwrapped for easier access.
 *
 * @example
 * ```ts
 * import { api } from '@convex/api';
 * import type { inferApiInputs } from 'kitcn/server';
 *
 * type AppRouter = typeof api & { http?: typeof httpRouter };
 * type ApiInputs = inferApiInputs<AppRouter>;
 *
 * type ScrapeLinkInput = ApiInputs['scraper']['scrapeLink'];
 * type CreateTodoInput = ApiInputs['http']['todos']['create'];
 * ```
 */
type inferApiInputs<TApi> = { [K in keyof TApi as PublicApiKey<K>]-?: InferInputsRecursive<UnwrapOptional<TApi[K]>> };
//#endregion
//#region src/server/procedure-caller.d.ts
type ProcedureType = 'query' | 'mutation' | 'action';
type CallerContextType = 'query' | 'mutation';
type ScheduledFunctionId = GenericId<'_scheduled_functions'>;
type RecordLike = Record<string, unknown>;
type ProcedureTree = RecordLike;
type ProcedureDefinition<TType extends ProcedureType, TProcedure> = Readonly<{
  _type: TType;
  __procedure?: TProcedure;
}>;
type ProcedureHandlerType<TProcedure> = NonNullable<TProcedure extends {
  _handler?: infer THandler;
} ? THandler : never>;
type ProcedureTypeHintInput<TProcedure> = TProcedure extends {
  __kitcnTypeHint?: {
    args: infer TArgs;
  };
} ? TArgs : never;
type ProcedureTypeHintOutput<TProcedure> = TProcedure extends {
  __kitcnTypeHint?: {
    returns: infer TReturns;
  };
} ? TReturns : never;
type InferredHandlerInput<TProcedure> = ProcedureHandlerType<TProcedure> extends ((ctx: unknown, input: infer TInput, ...rest: any[]) => unknown) ? TInput : Record<string, never>;
type InferredHandlerOutput<TProcedure> = ProcedureHandlerType<TProcedure> extends ((...args: any[]) => infer TResult) ? Awaited<TResult> : never;
type ProcedureInput<TProcedure> = [ProcedureTypeHintInput<TProcedure>] extends [never] ? InferredHandlerInput<TProcedure> : ProcedureTypeHintInput<TProcedure>;
type ProcedureOutput<TProcedure> = [ProcedureTypeHintOutput<TProcedure>] extends [never] ? InferredHandlerOutput<TProcedure> : ProcedureTypeHintOutput<TProcedure>;
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>;
type ProcedureCallable<TProcedure> = ProcedureCallableWithOutput<TProcedure, ProcedureOutput<TProcedure>>;
type ProcedureSchedulableCallable<TProcedure> = ProcedureCallableWithOutput<TProcedure, ScheduledFunctionId>;
type SchedulableProcedureType = Exclude<ProcedureType, 'query'>;
type AllowedProcedureType<TCtxType extends CallerContextType> = TCtxType extends 'query' ? 'query' : 'query' | 'mutation';
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;
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;
type CallerForContext<TApi, TCtx, TQueryCtx, TMutationCtx> = TCtx extends TMutationCtx ? ProcedureCaller<TApi, 'mutation'> : TCtx extends TQueryCtx ? ProcedureCaller<TApi, 'query'> : never;
type UnionToIntersection<TUnion> = (TUnion extends unknown ? (value: TUnion) => void : never) extends ((value: infer TIntersection) => void) ? TIntersection : never;
type Simplify<TObject> = { [K in keyof TObject]: TObject[K] } & {};
type SimplifyDeep<TObject> = TObject extends Record<string, unknown> ? Simplify<{ [K in keyof TObject]: SimplifyDeep<TObject[K]> }> : TObject;
type SplitPath<TPath extends string> = TPath extends `${infer THead}.${infer TRest}` ? [THead, ...SplitPath<TRest>] : TPath extends '' ? [] : [TPath];
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;
type ResolverOutput<TResolver> = TResolver extends ((...args: any[]) => infer TResult) ? Awaited<TResult> : never;
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>>>> : {} : {};
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>>>> : {} : {};
type GeneratedProcedureRegistryEntry<TType extends ProcedureType = ProcedureType, TResolver extends (...args: any[]) => unknown = (...args: any[]) => unknown> = readonly [TType, TResolver];
type GeneratedProcedureRegistry = Record<string, GeneratedProcedureRegistryEntry>;
type ProcedureCallerFromRegistryByAllowedTypes<TRegistry extends GeneratedProcedureRegistry, TAllowed extends ProcedureType> = SimplifyDeep<UnionToIntersection<{ [K in keyof TRegistry & string]: RegistryEntryToPathShape<K, TRegistry[K], TAllowed> }[keyof TRegistry & string]>>;
type ProcedureCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry, TCtxType extends CallerContextType> = TCtxType extends 'query' ? ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query'> : ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query' | 'mutation'>;
type ProcedureActionCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry> = ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'action'>;
type ProcedureSchedulableCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry> = SimplifyDeep<UnionToIntersection<{ [K in keyof TRegistry & string]: RegistryEntryToSchedulablePathShape<K, TRegistry[K], SchedulableProcedureType> }[keyof TRegistry & string]>>;
type ProcedureScheduleCallerFromRegistry<TRegistry extends GeneratedProcedureRegistry> = {
  after: (delayMs: number) => ProcedureSchedulableCallerFromRegistry<TRegistry>;
  at: (timestamp: number | Date) => ProcedureSchedulableCallerFromRegistry<TRegistry>;
  now: ProcedureSchedulableCallerFromRegistry<TRegistry>;
  cancel: (id: ScheduledFunctionId) => Promise<void>;
};
type ProcedureMutationCallerWithSchedule<TRegistry extends GeneratedProcedureRegistry> = SimplifyDeep<ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query' | 'mutation'> & {
  schedule: ProcedureScheduleCallerFromRegistry<TRegistry>;
}>;
type ProcedureActionCallerWithNamespaces<TRegistry extends GeneratedProcedureRegistry> = SimplifyDeep<ProcedureCallerFromRegistryByAllowedTypes<TRegistry, 'query' | 'mutation'> & {
  actions: ProcedureActionCallerFromRegistry<TRegistry>;
  schedule: ProcedureScheduleCallerFromRegistry<TRegistry>;
}>;
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;
type GeneratedRegistryHandlerForContext<TRegistry extends GeneratedProcedureRegistry, TCtx, TQueryCtx, TMutationCtx> = TCtx extends TMutationCtx ? ProcedureCallerFromRegistry<TRegistry, 'mutation'> : TCtx extends TQueryCtx ? ProcedureCallerFromRegistry<TRegistry, 'query'> : never;
type CreateProcedureCallerFactoryOptions<TApi extends ProcedureTree> = {
  api: TApi;
  resolver: (path: string[]) => Promise<unknown> | unknown;
};
type AnyProcedureFunctionReference = FunctionReference<'query' | 'mutation' | 'action', any, any, any>;
type ProcedureTypeFromFunctionReference<TFunctionReference extends AnyProcedureFunctionReference> = TFunctionReference extends FunctionReference<infer TProcedureType, any, any, any> ? TProcedureType extends ProcedureType ? TProcedureType : never : never;
type ProcedureFromFunctionReference<TFunctionReference extends AnyProcedureFunctionReference> = CRPCFunctionTypeHint<TFunctionReference['_args'], FunctionReturnType<TFunctionReference>> & {
  _crpcMeta?: {
    type?: ProcedureTypeFromFunctionReference<TFunctionReference>;
  };
  _handler?: (ctx: unknown, input: TFunctionReference['_args']) => FunctionReturnType<TFunctionReference> | Promise<FunctionReturnType<TFunctionReference>>;
};
type ProcedureResolverFromFunctionReference<TFunctionReference extends AnyProcedureFunctionReference> = () => ProcedureFromFunctionReference<TFunctionReference> | Promise<ProcedureFromFunctionReference<TFunctionReference>>;
declare function typedProcedureResolver<TFunctionReference extends AnyProcedureFunctionReference>(functionReference: TFunctionReference, resolver: () => unknown | Promise<unknown>): ProcedureResolverFromFunctionReference<TFunctionReference>;
declare function getGeneratedFunctionReference<TFunctionReference extends AnyProcedureFunctionReference>(functionReference: TFunctionReference): TFunctionReference;
declare function defineProcedure<TType extends ProcedureType, TProcedure>(type: TType): ProcedureDefinition<TType, TProcedure>;
declare function createProcedureCallerFactory<TQueryCtx, TMutationCtx, TApi extends ProcedureTree>(opts: CreateProcedureCallerFactoryOptions<TApi>): <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => CallerForContext<TApi, TCtx, TQueryCtx, TMutationCtx>;
declare function createProcedureHandlerFactory<TQueryCtx, TMutationCtx, TApi extends ProcedureTree>(opts: CreateProcedureCallerFactoryOptions<TApi>): <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => CallerForContext<TApi, TCtx, TQueryCtx, TMutationCtx>;
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>;
declare function createGenericHandlerFactory<TQueryCtx, TMutationCtx, TRegistry extends GeneratedProcedureRegistry>(registry: TRegistry): <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => GeneratedRegistryHandlerForContext<TRegistry, TCtx, TQueryCtx, TMutationCtx>;
type GeneratedRegistryCallerFactory<TQueryCtx, TMutationCtx, TRegistry extends GeneratedProcedureRegistry, TActionCtx = never> = <TCtx extends TQueryCtx | TMutationCtx | TActionCtx>(ctx: TCtx) => GeneratedRegistryCallerForContext<TRegistry, TCtx, TQueryCtx, TMutationCtx, TActionCtx>;
type GeneratedRegistryHandlerFactory<TQueryCtx, TMutationCtx, TRegistry extends GeneratedProcedureRegistry> = <TCtx extends TQueryCtx | TMutationCtx>(ctx: TCtx) => GeneratedRegistryHandlerForContext<TRegistry, TCtx, TQueryCtx, TMutationCtx>;
type GeneratedRegistryRuntime<TQueryCtx, TMutationCtx, TCallerRegistry extends GeneratedProcedureRegistry, TActionCtx = never> = {
  getCallerFactory: () => GeneratedRegistryCallerFactory<TQueryCtx, TMutationCtx, TCallerRegistry, TActionCtx>;
};
type GeneratedRegistryRuntimeWithHandler<TQueryCtx, TMutationCtx, TCallerRegistry extends GeneratedProcedureRegistry, THandlerRegistry extends GeneratedProcedureRegistry, TActionCtx = never> = GeneratedRegistryRuntime<TQueryCtx, TMutationCtx, TCallerRegistry, TActionCtx> & {
  getHandlerFactory: () => GeneratedRegistryHandlerFactory<TQueryCtx, TMutationCtx, THandlerRegistry>;
};
type GeneratedRegistryBundle<TCallerRegistry extends GeneratedProcedureRegistry, THandlerRegistry extends GeneratedProcedureRegistry | undefined = undefined> = {
  procedureRegistry: TCallerRegistry;
  handlerRegistry?: THandlerRegistry;
};
type GeneratedRegistrySource<TCallerRegistry extends GeneratedProcedureRegistry, THandlerRegistry extends GeneratedProcedureRegistry | undefined = undefined> = GeneratedRegistryBundle<TCallerRegistry, THandlerRegistry> | (() => GeneratedRegistryBundle<TCallerRegistry, THandlerRegistry>);
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>;
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>;
//#endregion
//#region src/server/procedure-name.d.ts
type ProcedureNameEntry = {
  column: number;
  line: number;
  name: string;
};
type ProcedureNameLookup = Record<string, ProcedureNameEntry[]>;
declare function registerProcedureNameLookup(lookup: ProcedureNameLookup, functionsDirHint: string): void;
declare function inferProcedureNameFromCallsite(): string | undefined;
//#endregion
export { CRPCFunctionTypeHint as $, CRPCError as A, createEnv as B, createProcedureHandlerFactory as C, zid as Ct, WithHttpRouter as D, zodToConvexFields as Dt, typedProcedureResolver as E, zodToConvex as Et, getCRPCErrorFromUnknown as F, CallerMeta as G, createCallerFactory as H, getHTTPStatusCodeFromError as I, createServerCaller as J, CallerOpts as K, isCRPCError as L, CRPCErrorData as M, CRPC_ERROR_CODES_BY_KEY as N, inferApiInputs as O, CRPC_ERROR_CODE_TO_HTTP as P, ActionProcedureBuilder as Q, toCRPCError as R, createProcedureCallerFactory as S, zCustomQuery as St, getGeneratedFunctionReference as T, zodOutputToConvexFields as Tt, LazyCaller as U, ConvexContext as V, createLazyCaller as W, createGeneratedFunctionReference as X, createApiLeaf as Y, getGeneratedValue as Z, ProcedureSchedulableCallerFromRegistry as _, convexToZod as _t, CreateProcedureCallerFactoryOptions as a, HttpProcedureBuilder as at, createGenericCallerFactory as b, zCustomAction as bt, GeneratedRegistryCallerFactory as c, handleHttpError as ct, GeneratedRegistryHandlerForContext as d, ConvexValidatorFromZodOutput as dt, MutationProcedureBuilder as et, ProcedureActionCallerFromRegistry as f, CustomBuilder as ft, ProcedureFromFunctionReference as g, ZodValidatorFromConvex as gt, ProcedureDefinition as h, ZodFromValidatorBase as ht, registerProcedureNameLookup as i, initCRPC as it, CRPCErrorCode as j, inferApiOutputs as k, GeneratedRegistryCallerForContext as l, matchPathParams as lt, ProcedureCallerFromRegistry as m, Zid as mt, ProcedureNameLookup as n, QueryProcedureBuilder as nt, GeneratedProcedureRegistry as o, createHttpProcedureBuilder as ot, ProcedureCaller as p, ZCustomCtx as pt, ServerCaller as q, inferProcedureNameFromCallsite as r, createMiddlewareFactory as rt, GeneratedProcedureRegistryEntry as s, extractPathParams as st, ProcedureNameEntry as t, ProcedureBuilder as tt, GeneratedRegistryHandlerFactory as u, ConvexValidatorFromZod as ut, ProcedureScheduleCallerFromRegistry as v, convexToZodFields as vt, defineProcedure as w, zodOutputToConvex as wt, createGenericHandlerFactory as x, zCustomMutation as xt, createGeneratedRegistryRuntime as y, withSystemFields as yt, CreateEnvOptions as z };