88 * @module
99 */
1010
11- import {
11+ import type {
1212 ActionBuilder ,
13- AnyComponents ,
1413 HttpActionBuilder ,
1514 MutationBuilder ,
1615 QueryBuilder ,
@@ -19,15 +18,18 @@ import {
1918 GenericQueryCtx ,
2019 GenericDatabaseReader ,
2120 GenericDatabaseWriter ,
22- FunctionReference ,
21+ } from "convex/server" ;
22+ import {
23+ actionGeneric ,
24+ httpActionGeneric ,
25+ queryGeneric ,
26+ mutationGeneric ,
27+ internalActionGeneric ,
28+ internalMutationGeneric ,
29+ internalQueryGeneric ,
2330} from "convex/server" ;
2431import type { DataModel } from "./dataModel.js" ;
2532
26- type GenericCtx =
27- | GenericActionCtx < DataModel >
28- | GenericMutationCtx < DataModel >
29- | GenericQueryCtx < DataModel > ;
30-
3133/**
3234 * Define a query in this Convex app's public API.
3335 *
@@ -36,7 +38,7 @@ type GenericCtx =
3638 * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
3739 * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
3840 */
39- export declare const query : QueryBuilder < DataModel , "public" > ;
41+ export const query : QueryBuilder < DataModel , "public" > = queryGeneric ;
4042
4143/**
4244 * Define a query that is only accessible from other Convex functions (but not from the client).
@@ -46,7 +48,8 @@ export declare const query: QueryBuilder<DataModel, "public">;
4648 * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
4749 * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
4850 */
49- export declare const internalQuery : QueryBuilder < DataModel , "internal" > ;
51+ export const internalQuery : QueryBuilder < DataModel , "internal" > =
52+ internalQueryGeneric ;
5053
5154/**
5255 * Define a mutation in this Convex app's public API.
@@ -56,7 +59,7 @@ export declare const internalQuery: QueryBuilder<DataModel, "internal">;
5659 * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
5760 * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
5861 */
59- export declare const mutation : MutationBuilder < DataModel , "public" > ;
62+ export const mutation : MutationBuilder < DataModel , "public" > = mutationGeneric ;
6063
6164/**
6265 * Define a mutation that is only accessible from other Convex functions (but not from the client).
@@ -66,7 +69,8 @@ export declare const mutation: MutationBuilder<DataModel, "public">;
6669 * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
6770 * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
6871 */
69- export declare const internalMutation : MutationBuilder < DataModel , "internal" > ;
72+ export const internalMutation : MutationBuilder < DataModel , "internal" > =
73+ internalMutationGeneric ;
7074
7175/**
7276 * Define an action in this Convex app's public API.
@@ -79,36 +83,42 @@ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
7983 * @param func - The action. It receives an {@link ActionCtx} as its first argument.
8084 * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
8185 */
82- export declare const action : ActionBuilder < DataModel , "public" > ;
86+ export const action : ActionBuilder < DataModel , "public" > = actionGeneric ;
8387
8488/**
8589 * Define an action that is only accessible from other Convex functions (but not from the client).
8690 *
8791 * @param func - The function. It receives an {@link ActionCtx} as its first argument.
8892 * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
8993 */
90- export declare const internalAction : ActionBuilder < DataModel , "internal" > ;
94+ export const internalAction : ActionBuilder < DataModel , "internal" > =
95+ internalActionGeneric ;
9196
9297/**
9398 * Define an HTTP action.
9499 *
95- * This function will be used to respond to HTTP requests received by a Convex
96- * deployment if the requests matches the path and method where this action
97- * is routed. Be sure to route your action in `convex/http.js`.
100+ * The wrapped function will be used to respond to HTTP requests received
101+ * by a Convex deployment if the requests matches the path and method where
102+ * this action is routed. Be sure to route your httpAction in `convex/http.js`.
98103 *
99- * @param func - The function. It receives an {@link ActionCtx} as its first argument.
104+ * @param func - The function. It receives an {@link ActionCtx} as its first argument
105+ * and a Fetch API `Request` object as its second.
100106 * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
101107 */
102- export declare const httpAction : HttpActionBuilder ;
108+ export const httpAction : HttpActionBuilder = httpActionGeneric ;
109+
110+ type GenericCtx =
111+ | GenericActionCtx < DataModel >
112+ | GenericMutationCtx < DataModel >
113+ | GenericQueryCtx < DataModel > ;
103114
104115/**
105116 * A set of services for use within Convex query functions.
106117 *
107118 * The query context is passed as the first argument to any Convex query
108119 * function run on the server.
109120 *
110- * This differs from the {@link MutationCtx} because all of the services are
111- * read-only.
121+ * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
112122 */
113123export type QueryCtx = GenericQueryCtx < DataModel > ;
114124
@@ -117,6 +127,8 @@ export type QueryCtx = GenericQueryCtx<DataModel>;
117127 *
118128 * The mutation context is passed as the first argument to any Convex mutation
119129 * function run on the server.
130+ *
131+ * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
120132 */
121133export type MutationCtx = GenericMutationCtx < DataModel > ;
122134
0 commit comments