Skip to content

Commit 187d74c

Browse files
committed
Update to Convex 0.13.0
1 parent 1a1c6d6 commit 187d74c

File tree

14 files changed

+209
-94
lines changed

14 files changed

+209
-94
lines changed

convex/_generated/api.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* THIS CODE IS AUTOMATICALLY GENERATED.
66
*
7-
* Generated by convex@0.9.2.
7+
* Generated by convex@0.13.0.
88
* To regenerate, run `npx convex codegen`.
99
* @module
1010
*/

convex/_generated/dataModel.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* THIS CODE IS AUTOMATICALLY GENERATED.
66
*
7-
* Generated by convex@0.9.2.
7+
* Generated by convex@0.13.0.
88
* To regenerate, run `npx convex codegen`.
99
* @module
1010
*/
@@ -24,7 +24,7 @@ export type TableNames = TableNamesInDataModel<DataModel>;
2424
*
2525
* @typeParam TableName - A string literal type of the table name (like "users").
2626
*/
27-
export type Document<TableName extends TableNames> = DocumentByName<
27+
export type Doc<TableName extends TableNames> = DocumentByName<
2828
DataModel,
2929
TableName
3030
>;

convex/_generated/dataModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* THIS CODE IS AUTOMATICALLY GENERATED.
66
*
7-
* Generated by convex@0.9.2.
7+
* Generated by convex@0.13.0.
88
* To regenerate, run `npx convex codegen`.
99
* @module
1010
*/

convex/_generated/react.d.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* THIS CODE IS AUTOMATICALLY GENERATED.
66
*
7-
* Generated by convex@0.9.2.
7+
* Generated by convex@0.13.0.
88
* To regenerate, run `npx convex codegen`.
99
* @module
1010
*/
@@ -85,7 +85,8 @@ export declare const useConvex: UseConvexForAPI<API>;
8585
*
8686
* This hook must be used with Convex query functions that match
8787
* {@link PaginatedQueryFunction}. This means they must:
88-
* 1. Have a first argument must be an object containing `numItems` and `cursor`.
88+
* 1. Have a single arguments object with a `paginationOpts` property
89+
* of type {@link server.PaginationOptions}.
8990
* 2. Return a {@link PaginationResult}.
9091
*
9192
* `usePaginatedQuery` concatenates all the pages
@@ -96,15 +97,23 @@ export declare const useConvex: UseConvexForAPI<API>;
9697
* ```typescript
9798
* const { results, status, loadMore } = usePaginatedQuery(
9899
* "listMessages",
99-
* { initialNumItems: 5 },
100-
* "#general"
100+
* { channel: "#general" },
101+
* { initialNumItems: 5 }
101102
* );
102103
* ```
103104
*
105+
* If the query `name` or `args` change, the pagination state will be reset
106+
* to the first page. Similarly, if any of the pages result in an InvalidCursor
107+
* or QueryScannedTooManyDocuments error, the pagination state will also reset
108+
* to the first page.
109+
*
110+
* To learn more about pagination, see [Paginated Queries](https://docs.convex.dev/using/pagination).
111+
*
104112
* @param name - The name of the query function.
113+
* @param args - The arguments object for the query function, excluding
114+
* the `paginationOpts` property. That property is injected by this hook.
105115
* @param options - An object specifying the `initialNumItems` to be loaded in
106116
* the first page.
107-
* @param args - The arguments to the query function, excluding the first.
108117
* @returns A {@link UsePaginatedQueryResult} that includes the currently loaded
109118
* items, the status of the pagination, and a `loadMore` function.
110119
*/

convex/_generated/react.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* THIS CODE IS AUTOMATICALLY GENERATED.
66
*
7-
* Generated by convex@0.9.2.
7+
* Generated by convex@0.13.0.
88
* To regenerate, run `npx convex codegen`.
99
* @module
1010
*/
@@ -83,7 +83,8 @@ export const useConvex = useConvexGeneric;
8383
*
8484
* This hook must be used with Convex query functions that match
8585
* {@link PaginatedQueryFunction}. This means they must:
86-
* 1. Have a first argument must be an object containing `numItems` and `cursor`.
86+
* 1. Have a single arguments object with a `paginationOpts` property
87+
* of type {@link server.PaginationOptions}.
8788
* 2. Return a {@link PaginationResult}.
8889
*
8990
* `usePaginatedQuery` concatenates all the pages
@@ -94,8 +95,8 @@ export const useConvex = useConvexGeneric;
9495
* ```typescript
9596
* const { results, status, loadMore } = usePaginatedQuery(
9697
* "listMessages",
97-
* { initialNumItems: 5 },
98-
* "#general"
98+
* { channel: "#general" },
99+
* { initialNumItems: 5 }
99100
* );
100101
* ```
101102
*
@@ -107,9 +108,10 @@ export const useConvex = useConvexGeneric;
107108
* To learn more about pagination, see [Paginated Queries](https://docs.convex.dev/using/pagination).
108109
*
109110
* @param name - The name of the query function.
111+
* @param args - The arguments object for the query function, excluding
112+
* the `paginationOpts` property. That property is injected by this hook.
110113
* @param options - An object specifying the `initialNumItems` to be loaded in
111114
* the first page.
112-
* @param args - The arguments to the query function, excluding the first.
113115
* @returns A {@link UsePaginatedQueryResult} that includes the currently loaded
114116
* items, the status of the pagination, and a `loadMore` function.
115117
*/

convex/_generated/server.d.ts

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
*
55
* THIS CODE IS AUTOMATICALLY GENERATED.
66
*
7-
* Generated by convex@0.9.2.
7+
* Generated by convex@0.13.0.
88
* To regenerate, run `npx convex codegen`.
99
* @module
1010
*/
1111

1212
import {
13-
ActionBuilderForAPI,
14-
HttpEndpointBuilderForAPI,
13+
ActionBuilder,
14+
HttpActionBuilderForAPI,
1515
MutationBuilder,
16-
QueryBuilderForDataModel,
16+
QueryBuilder,
17+
CronJobsForAPI,
1718
ActionCtx as GenericActionCtx,
18-
HttpEndpointCtx as GenericHttpEndpointCtx,
1919
MutationCtx as GenericMutationCtx,
2020
QueryCtx as GenericQueryCtx,
2121
DatabaseReader as GenericDatabaseReader,
@@ -24,6 +24,30 @@ import {
2424
import type { DataModel } from "./dataModel.js";
2525
import type { API } from "./api.js";
2626

27+
/**
28+
* Returns a cron job scheduler, used to schedule Convex functions to run on a recurring basis.
29+
*
30+
* ```js
31+
* // convex/crons.js
32+
* import { cronJobs } from './_generated/server';
33+
*
34+
* const crons = cronJobs();
35+
* crons.weekly(
36+
* "weekly re-engagement email",
37+
* {
38+
* hourUTC: 17, // (9:30am Pacific/10:30am Daylight Savings Pacific)
39+
* minuteUTC: 30,
40+
* },
41+
* "sendEmails"
42+
* )
43+
* export default crons;
44+
* ```
45+
*
46+
* @returns The cron job scheduler object. Create this object in `convex/crons.js` and export it
47+
* as the default export.
48+
*/
49+
export declare const cronJobs: CronJobsForAPI<API>;
50+
2751
/**
2852
* Define a query in this Convex app's public API.
2953
*
@@ -32,7 +56,17 @@ import type { API } from "./api.js";
3256
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
3357
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
3458
*/
35-
export declare const query: QueryBuilderForDataModel<DataModel>;
59+
export declare const query: QueryBuilder<DataModel, "public">;
60+
61+
/**
62+
* Define a query that is only accessible from other Convex functions (but not from the client).
63+
*
64+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
65+
*
66+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
67+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
68+
*/
69+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
3670

3771
/**
3872
* Define a mutation in this Convex app's public API.
@@ -42,34 +76,54 @@ export declare const query: QueryBuilderForDataModel<DataModel>;
4276
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
4377
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
4478
*/
45-
export declare const mutation: MutationBuilder<DataModel, API>;
79+
export declare const mutation: MutationBuilder<DataModel, API, "public">;
80+
81+
/**
82+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
83+
*
84+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
85+
*
86+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
87+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
88+
*/
89+
export declare const internalMutation: MutationBuilder<
90+
DataModel,
91+
API,
92+
"internal"
93+
>;
4694

4795
/**
4896
* Define an action in this Convex app's public API.
4997
*
5098
* An action is a function which can execute any JavaScript code, including non-deterministic
51-
* code and code with side-effects. Actions are often used to call into third-party services.
52-
* Actions execute in a Node.js environment and can interact with the database indirectly by
53-
* calling queries and mutations via the provided {@link ActionCtx} object. Actions need to be defined
54-
* in the `/convex/actions directory`. Queries and mutations, on the other hand, must be defined
55-
* outside of the `/convex/actions directory`.
99+
* code and code with side-effects, like calling third-party services.
100+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
101+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
56102
*
57-
* @param func - The action. It receives a {@link ActionCtx} as its first argument.
103+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
58104
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
59105
*/
60-
export declare const action: ActionBuilderForAPI<API>;
106+
export declare const action: ActionBuilder<API, "public">;
107+
108+
/**
109+
* Define an action that is only accessible from other Convex functions (but not from the client).
110+
*
111+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
112+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
113+
*/
114+
export declare const internalAction: ActionBuilder<API, "internal">;
61115

62116
/**
63-
* Define an HTTP endpoint.
117+
* Define an HTTP action.
64118
*
65119
* This function will be used to respond to HTTP requests received by a Convex
66-
* deployment if the requests matches the path and method where this endpoint
67-
* is routed. Be sure to route your endpoint in `convex/http.js`.
120+
* deployment if the requests matches the path and method where this action
121+
* is routed. Be sure to route your action in `convex/http.js`.
68122
*
69-
* @param func - The endpoint function. It receives a {@link HttpEndpointCtx} as its first argument.
70-
* @returns The wrapped endpoint function. Import this function from `convex/http.js` and route it to hook it up.
123+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
124+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
71125
*/
72-
export declare const httpEndpoint: HttpEndpointBuilderForAPI<API>;
126+
export declare const httpAction: HttpActionBuilderForAPI<API>;
73127

74128
/**
75129
* A set of services for use within Convex query functions.
@@ -98,14 +152,6 @@ export type MutationCtx = GenericMutationCtx<DataModel, API>;
98152
*/
99153
export type ActionCtx = GenericActionCtx<API>;
100154

101-
/**
102-
* A set of services for use within Convex HTTP endpoints.
103-
*
104-
* The HttpEndpointCtx is passed as the first argument to any Convex HTTP
105-
* endpoint run on the server.
106-
*/
107-
export type HttpEndpointCtx = GenericHttpEndpointCtx<API>;
108-
109155
/**
110156
* An interface to read from the database within Convex query functions.
111157
*

convex/_generated/server.js

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44
*
55
* THIS CODE IS AUTOMATICALLY GENERATED.
66
*
7-
* Generated by convex@0.9.2.
7+
* Generated by convex@0.13.0.
88
* To regenerate, run `npx convex codegen`.
99
* @module
1010
*/
1111

1212
import {
1313
actionGeneric,
14-
httpEndpointGeneric,
14+
httpActionGeneric,
1515
queryGeneric,
1616
mutationGeneric,
17+
internalActionGeneric,
18+
internalMutationGeneric,
19+
internalQueryGeneric,
20+
cronJobsGeneric,
1721
} from "convex/server";
1822

1923
/**
@@ -26,6 +30,16 @@ import {
2630
*/
2731
export const query = queryGeneric;
2832

33+
/**
34+
* Define a query that is only accessible from other Convex functions (but not from the client).
35+
*
36+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
37+
*
38+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
39+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
40+
*/
41+
export const internalQuery = internalQueryGeneric;
42+
2943
/**
3044
* Define a mutation in this Convex app's public API.
3145
*
@@ -36,26 +50,66 @@ export const query = queryGeneric;
3650
*/
3751
export const mutation = mutationGeneric;
3852

53+
/**
54+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
55+
*
56+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
57+
*
58+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
59+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
60+
*/
61+
export const internalMutation = internalMutationGeneric;
62+
3963
/**
4064
* Define an action in this Convex app's public API.
4165
*
4266
* An action is a function which can execute any JavaScript code, including non-deterministic
43-
* code and code with side-effects. Actions are often used to call into third-party services.
44-
* Actions execute in a Node.js environment and can interact with the database indirectly by
45-
* calling queries and mutations via the provided {@link ActionCtx} object. Actions need to be defined
46-
* in the `/convex/actions directory`. Queries and mutations, on the other hand, must be defined
47-
* outside of the `/convex/actions directory`.
67+
* code and code with side-effects, like calling third-party services.
68+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
69+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
4870
*
49-
* @param func - The action. It receives a {@link ActionCtx} as its first argument.
71+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
5072
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
5173
*/
5274
export const action = actionGeneric;
5375

5476
/**
55-
* Define a Convex HTTP endpoint.
77+
* Define an action that is only accessible from other Convex functions (but not from the client).
78+
*
79+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
80+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
81+
*/
82+
export const internalAction = internalActionGeneric;
83+
84+
/**
85+
* Define a Convex HTTP action.
5686
*
57-
* @param func - The function. It receives an {@link HttpEndpointCtx} as its first argument, and a `Request` object
87+
* @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
5888
* as its second.
5989
* @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
6090
*/
61-
export const httpEndpoint = httpEndpointGeneric;
91+
export const httpAction = httpActionGeneric;
92+
93+
/**
94+
* Returns a cron job scheduler, used to schedule Convex functions to run on a recurring basis.
95+
*
96+
* ```js
97+
* // convex/crons.js
98+
* import { cronJobs } from './_generated/server';
99+
*
100+
* const crons = cronJobs();
101+
* crons.weekly(
102+
* "weekly re-engagement email",
103+
* {
104+
* hourUTC: 17, // (9:30am Pacific/10:30am Daylight Savings Pacific)
105+
* minuteUTC: 30,
106+
* },
107+
* "sendEmails"
108+
* )
109+
* export default crons;
110+
* ```
111+
*
112+
* @returns The cron job scheduler object. Create this object in `convex/crons.js` and export it
113+
* as the default export.
114+
*/
115+
export const cronJobs = cronJobsGeneric;

0 commit comments

Comments
 (0)