Skip to content

Commit a26adc3

Browse files
committed
update codegen
1 parent bdfc511 commit a26adc3

File tree

7 files changed

+54
-157
lines changed

7 files changed

+54
-157
lines changed

example/convex/_generated/server.d.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import {
1212
ActionBuilder,
13-
AnyComponents,
1413
HttpActionBuilder,
1514
MutationBuilder,
1615
QueryBuilder,
@@ -19,15 +18,9 @@ import {
1918
GenericQueryCtx,
2019
GenericDatabaseReader,
2120
GenericDatabaseWriter,
22-
FunctionReference,
2321
} from "convex/server";
2422
import type { DataModel } from "./dataModel.js";
2523

26-
type GenericCtx =
27-
| GenericActionCtx<DataModel>
28-
| GenericMutationCtx<DataModel>
29-
| GenericQueryCtx<DataModel>;
30-
3124
/**
3225
* Define a query in this Convex app's public API.
3326
*
@@ -92,11 +85,12 @@ export declare const internalAction: ActionBuilder<DataModel, "internal">;
9285
/**
9386
* Define an HTTP action.
9487
*
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`.
88+
* The wrapped function will be used to respond to HTTP requests received
89+
* by a Convex deployment if the requests matches the path and method where
90+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
9891
*
99-
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
92+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
93+
* and a Fetch API `Request` object as its second.
10094
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
10195
*/
10296
export declare const httpAction: HttpActionBuilder;

example/convex/_generated/server.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
internalActionGeneric,
1717
internalMutationGeneric,
1818
internalQueryGeneric,
19-
componentsGeneric,
2019
} from "convex/server";
2120

2221
/**
@@ -81,10 +80,14 @@ export const action = actionGeneric;
8180
export const internalAction = internalActionGeneric;
8281

8382
/**
84-
* Define a Convex HTTP action.
83+
* Define an HTTP action.
8584
*
86-
* @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
87-
* as its second.
88-
* @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
85+
* The wrapped function will be used to respond to HTTP requests received
86+
* by a Convex deployment if the requests matches the path and method where
87+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
88+
*
89+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
90+
* and a Fetch API `Request` object as its second.
91+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
8992
*/
9093
export const httpAction = httpActionGeneric;

src/component/_generated/api.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/component/_generated/api.d.ts renamed to src/component/_generated/api.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ import type {
1717
FilterApi,
1818
FunctionReference,
1919
} from "convex/server";
20+
import { anyApi, componentsGeneric } from "convex/server";
2021

21-
declare const fullApi: ApiFromModules<{
22+
const fullApi: ApiFromModules<{
2223
messages: typeof messages;
2324
phone_numbers: typeof phone_numbers;
2425
utils: typeof utils;
25-
}>;
26+
}> = anyApi as any;
2627

2728
/**
2829
* A utility for referencing Convex functions in your app's public API.
@@ -32,10 +33,10 @@ declare const fullApi: ApiFromModules<{
3233
* const myFunctionReference = api.myModule.myFunction;
3334
* ```
3435
*/
35-
export declare const api: FilterApi<
36+
export const api: FilterApi<
3637
typeof fullApi,
3738
FunctionReference<any, "public">
38-
>;
39+
> = anyApi as any;
3940

4041
/**
4142
* A utility for referencing Convex functions in your app's internal API.
@@ -45,9 +46,9 @@ export declare const api: FilterApi<
4546
* const myFunctionReference = internal.myModule.myFunction;
4647
* ```
4748
*/
48-
export declare const internal: FilterApi<
49+
export const internal: FilterApi<
4950
typeof fullApi,
5051
FunctionReference<any, "internal">
51-
>;
52+
> = anyApi as any;
5253

53-
export declare const components: {};
54+
export const components = componentsGeneric() as unknown as {};
File renamed without changes.

src/component/_generated/server.js

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/component/_generated/server.d.ts renamed to src/component/_generated/server.ts

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
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";
2431
import 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
*/
113123
export 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
*/
121133
export type MutationCtx = GenericMutationCtx<DataModel>;
122134

0 commit comments

Comments
 (0)