UNPKG

@convex-dev/crons

Version:

Convex component for scheduling periodic jobs.

45 lines (40 loc) 992 B
// Type utilities for component clients. import type { Expand, FunctionReference, GenericDataModel, GenericMutationCtx, GenericQueryCtx, } from "convex/server"; import type { GenericId } from "convex/values"; export type RunQueryCtx = { runQuery: GenericQueryCtx<GenericDataModel>["runQuery"]; }; export type RunMutationCtx = { runMutation: GenericMutationCtx<GenericDataModel>["runMutation"]; }; export type OpaqueIds<T> = T extends GenericId<infer _T> ? string : T extends (infer U)[] ? OpaqueIds<U>[] : T extends object ? { [K in keyof T]: OpaqueIds<T[K]> } : T; export type UseApi<API> = Expand<{ [mod in keyof API]: API[mod] extends FunctionReference< infer FType, "public", infer FArgs, infer FReturnType, infer FComponentPath > ? FunctionReference< FType, "internal", OpaqueIds<FArgs>, OpaqueIds<FReturnType>, FComponentPath > : UseApi<API[mod]>; }>;