kitcn
Version:
kitcn - React Query integration and CLI tools for Convex
24 lines (23 loc) • 2.17 kB
TypeScript
import { GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx } from "convex/server";
//#region src/server/context-utils.d.ts
type GenericCtx<DataModel extends GenericDataModel = GenericDataModel> = GenericQueryCtx<DataModel> | GenericMutationCtx<DataModel> | GenericActionCtx<DataModel>;
type RunMutationCtx<DataModel extends GenericDataModel> = (GenericMutationCtx<DataModel> | GenericActionCtx<DataModel>) & {
runMutation: GenericMutationCtx<DataModel>['runMutation'];
};
type SchedulerCtx<TCtx> = TCtx extends {
scheduler?: infer TScheduler;
} ? TCtx & {
scheduler: NonNullable<TScheduler>;
} : never;
declare const isQueryCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is GenericQueryCtx<DataModel>;
declare const isMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is GenericMutationCtx<DataModel>;
declare const isActionCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is GenericActionCtx<DataModel>;
declare const isRunMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is RunMutationCtx<DataModel>;
declare const isSchedulerCtx: <TCtx extends object>(ctx: TCtx) => ctx is SchedulerCtx<TCtx>;
declare const requireQueryCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => GenericQueryCtx<DataModel>;
declare const requireMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => GenericMutationCtx<DataModel>;
declare const requireActionCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => GenericActionCtx<DataModel>;
declare const requireRunMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => RunMutationCtx<DataModel>;
declare const requireSchedulerCtx: <TCtx extends object>(ctx: TCtx) => SchedulerCtx<TCtx>;
//#endregion
export { isMutationCtx as a, isSchedulerCtx as c, requireQueryCtx as d, requireRunMutationCtx as f, isActionCtx as i, requireActionCtx as l, RunMutationCtx as n, isQueryCtx as o, requireSchedulerCtx as p, SchedulerCtx as r, isRunMutationCtx as s, GenericCtx as t, requireMutationCtx as u };