convex-helpers 0.1.124 → 0.1.125
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.d.ts +4 -4
- package/browser.d.ts.map +1 -1
- package/browser.ts +16 -4
- package/functionReferences.test.ts +359 -0
- package/package.json +2 -2
- package/react/cache/hooks.d.ts +5 -4
- package/react/cache/hooks.d.ts.map +1 -1
- package/react/cache/hooks.js +3 -1
- package/react/cache/hooks.ts +12 -7
- package/react/cache/provider.d.ts +2 -2
- package/react/cache/provider.d.ts.map +1 -1
- package/react/cache/provider.tsx +9 -2
- package/react/sessions.d.ts +5 -3
- package/react/sessions.d.ts.map +1 -1
- package/react/sessions.ts +10 -6
- package/react.d.ts +3 -3
- package/react.d.ts.map +1 -1
- package/react.test.ts +114 -0
- package/react.ts +5 -1
- package/server/migrations.d.ts +6 -5
- package/server/migrations.d.ts.map +1 -1
- package/server/migrations.ts +9 -4
- package/server/retries.d.ts +2 -2
- package/server/retries.d.ts.map +1 -1
- package/server/retries.ts +14 -6
- package/server/sessions.d.ts +4 -2
- package/server/sessions.d.ts.map +1 -1
- package/server/sessions.ts +13 -9
- package/testing.d.ts +4 -4
- package/testing.d.ts.map +1 -1
- package/testing.ts +14 -3
package/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BetterOmit, EmptyObject } from "./index.js";
|
|
2
2
|
import type { ConvexClient, ConvexHttpClient } from "convex/browser";
|
|
3
3
|
import type { FunctionArgs, FunctionReturnType } from "convex/server";
|
|
4
|
-
import type { FunctionReference } from "convex/server";
|
|
4
|
+
import type { FunctionReference, FunctionReference_future } from "convex/server";
|
|
5
5
|
import type { Value } from "convex/values";
|
|
6
6
|
export type ArgsArray<Injected extends Record<string, Value>, FullArgs extends Injected> = keyof FullArgs extends keyof Injected ? [args?: EmptyObject] : [args: BetterOmit<FullArgs, keyof Injected>];
|
|
7
7
|
/**
|
|
@@ -23,8 +23,8 @@ export type ArgsArray<Injected extends Record<string, Value>, FullArgs extends I
|
|
|
23
23
|
* @returns { query, mutation, action } functions with the injected arguments
|
|
24
24
|
*/
|
|
25
25
|
export declare function withArgs<A extends Record<string, Value>>(client: ConvexClient | ConvexHttpClient, injectedArgs: A): {
|
|
26
|
-
query<Query extends FunctionReference<"query">>(query: Query, ...args: ArgsArray<A, FunctionArgs<Query>>): Promise<Awaited<FunctionReturnType<Query>>>;
|
|
27
|
-
mutation<Mutation extends FunctionReference<"mutation">>(mutation: Mutation, ...args: ArgsArray<A, FunctionArgs<Mutation>>): Promise<Awaited<FunctionReturnType<Mutation>>>;
|
|
28
|
-
action<Action extends FunctionReference<"action">>(action: Action, ...args: ArgsArray<A, FunctionArgs<Action>>): Promise<Awaited<FunctionReturnType<Action>>>;
|
|
26
|
+
query<Query extends FunctionReference<"query"> | FunctionReference_future<"query">>(query: Query, ...args: ArgsArray<A, FunctionArgs<Query>>): Promise<Awaited<FunctionReturnType<Query>>>;
|
|
27
|
+
mutation<Mutation extends FunctionReference<"mutation"> | FunctionReference_future<"mutation">>(mutation: Mutation, ...args: ArgsArray<A, FunctionArgs<Mutation>>): Promise<Awaited<FunctionReturnType<Mutation>>>;
|
|
28
|
+
action<Action extends FunctionReference<"action"> | FunctionReference_future<"action">>(action: Action, ...args: ArgsArray<A, FunctionArgs<Action>>): Promise<Awaited<FunctionReturnType<Action>>>;
|
|
29
29
|
};
|
|
30
30
|
//# sourceMappingURL=browser.d.ts.map
|
package/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC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C,QAAQ,CAAC,CAAC,GAC5C,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAMjD,MAAM,CACJ,MAAM,SACJ,iBAAiB,CAAC,QAAQ,CAAC,GAAG,wBAAwB,CAAC,QAAQ,CAAC,UAE1D,MAAM,WACL,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,GAC1C,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;EAOlD"}
|
package/browser.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { BetterOmit, EmptyObject } from "./index.js";
|
|
2
2
|
import type { ConvexClient, ConvexHttpClient } from "convex/browser";
|
|
3
3
|
import type { FunctionArgs, FunctionReturnType } from "convex/server";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
FunctionReference,
|
|
6
|
+
FunctionReference_future,
|
|
7
|
+
} from "convex/server";
|
|
5
8
|
import type { Value } from "convex/values";
|
|
6
9
|
|
|
7
10
|
export type ArgsArray<
|
|
@@ -34,7 +37,10 @@ export function withArgs<A extends Record<string, Value>>(
|
|
|
34
37
|
injectedArgs: A,
|
|
35
38
|
) {
|
|
36
39
|
return {
|
|
37
|
-
query<
|
|
40
|
+
query<
|
|
41
|
+
Query extends
|
|
42
|
+
FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
43
|
+
>(
|
|
38
44
|
query: Query,
|
|
39
45
|
...args: ArgsArray<A, FunctionArgs<Query>>
|
|
40
46
|
): Promise<Awaited<FunctionReturnType<Query>>> {
|
|
@@ -43,7 +49,10 @@ export function withArgs<A extends Record<string, Value>>(
|
|
|
43
49
|
...injectedArgs,
|
|
44
50
|
} as FunctionArgs<Query>);
|
|
45
51
|
},
|
|
46
|
-
mutation<
|
|
52
|
+
mutation<
|
|
53
|
+
Mutation extends
|
|
54
|
+
FunctionReference<"mutation"> | FunctionReference_future<"mutation">,
|
|
55
|
+
>(
|
|
47
56
|
mutation: Mutation,
|
|
48
57
|
...args: ArgsArray<A, FunctionArgs<Mutation>>
|
|
49
58
|
): Promise<Awaited<FunctionReturnType<Mutation>>> {
|
|
@@ -52,7 +61,10 @@ export function withArgs<A extends Record<string, Value>>(
|
|
|
52
61
|
...injectedArgs,
|
|
53
62
|
} as FunctionArgs<Mutation>);
|
|
54
63
|
},
|
|
55
|
-
action<
|
|
64
|
+
action<
|
|
65
|
+
Action extends
|
|
66
|
+
FunctionReference<"action"> | FunctionReference_future<"action">,
|
|
67
|
+
>(
|
|
56
68
|
action: Action,
|
|
57
69
|
...args: ArgsArray<A, FunctionArgs<Action>>
|
|
58
70
|
): Promise<Awaited<FunctionReturnType<Action>>> {
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { expectTypeOf, test } from "vitest";
|
|
2
|
+
import type { ConvexClient } from "convex/browser";
|
|
3
|
+
import {
|
|
4
|
+
useQueries as useQueriesCore,
|
|
5
|
+
useQuery as useQueryCore,
|
|
6
|
+
usePaginatedQuery as usePaginatedQueryCore,
|
|
7
|
+
} from "convex/react";
|
|
8
|
+
import type {
|
|
9
|
+
FunctionArgs,
|
|
10
|
+
FunctionReference,
|
|
11
|
+
FunctionReference_future,
|
|
12
|
+
GenericActionCtx,
|
|
13
|
+
GenericDataModel,
|
|
14
|
+
PaginationOptions,
|
|
15
|
+
PaginationResult,
|
|
16
|
+
Scheduler,
|
|
17
|
+
} from "convex/server";
|
|
18
|
+
import { withArgs } from "./browser.js";
|
|
19
|
+
import {
|
|
20
|
+
makeUseQueryWithStatus,
|
|
21
|
+
useQuery,
|
|
22
|
+
usePaginatedQuery,
|
|
23
|
+
} from "./react.js";
|
|
24
|
+
import {
|
|
25
|
+
useQueries as useCachedQueries,
|
|
26
|
+
useQuery as useCachedQuery,
|
|
27
|
+
usePaginatedQuery as useCachedPaginatedQuery,
|
|
28
|
+
} from "./react/cache/hooks.js";
|
|
29
|
+
import {
|
|
30
|
+
ConvexReactSessionClient,
|
|
31
|
+
useSessionQuery,
|
|
32
|
+
useSessionMutation,
|
|
33
|
+
useSessionAction,
|
|
34
|
+
useSessionPaginatedQuery,
|
|
35
|
+
} from "./react/sessions.js";
|
|
36
|
+
import { runSessionFunctions, type SessionId } from "./server/sessions.js";
|
|
37
|
+
import {
|
|
38
|
+
startMigration,
|
|
39
|
+
startMigrationsSerially,
|
|
40
|
+
getStatus,
|
|
41
|
+
cancelMigration,
|
|
42
|
+
} from "./server/migrations.js";
|
|
43
|
+
import { makeActionRetrier } from "./server/retries.js";
|
|
44
|
+
import type { ConvexTestingHelper } from "./testing.js";
|
|
45
|
+
|
|
46
|
+
type Result = { value: string };
|
|
47
|
+
type Query = FunctionReference_future<
|
|
48
|
+
"query",
|
|
49
|
+
"public",
|
|
50
|
+
{ id: string },
|
|
51
|
+
Result
|
|
52
|
+
>;
|
|
53
|
+
type Mutation = FunctionReference_future<
|
|
54
|
+
"mutation",
|
|
55
|
+
"public",
|
|
56
|
+
{ id: string },
|
|
57
|
+
Result
|
|
58
|
+
>;
|
|
59
|
+
type Action = FunctionReference_future<
|
|
60
|
+
"action",
|
|
61
|
+
"public",
|
|
62
|
+
{ id: string },
|
|
63
|
+
Result
|
|
64
|
+
>;
|
|
65
|
+
type EmptyQuery = FunctionReference_future<
|
|
66
|
+
"query",
|
|
67
|
+
"public",
|
|
68
|
+
Record<string, never>,
|
|
69
|
+
Result
|
|
70
|
+
>;
|
|
71
|
+
|
|
72
|
+
test("query hooks match Convex 1.46 and compose with cached useQueries", () => {
|
|
73
|
+
expectTypeOf(useCachedQueries).toExtend<typeof useQueriesCore>();
|
|
74
|
+
expectTypeOf(useCachedQuery).toExtend<typeof useQueryCore>();
|
|
75
|
+
const useCachedQueryWithStatus = makeUseQueryWithStatus(useCachedQueries);
|
|
76
|
+
expectTypeOf(useCachedQueryWithStatus).toEqualTypeOf<typeof useQuery>();
|
|
77
|
+
|
|
78
|
+
// These callbacks are typechecked, but not run: hooks need a React render.
|
|
79
|
+
expectTypeOf((query: Query, empty: EmptyQuery, mutation: Mutation) => {
|
|
80
|
+
const result = useCachedQuery(query, { id: "one" });
|
|
81
|
+
expectTypeOf(result).toEqualTypeOf<Result | undefined>();
|
|
82
|
+
expectTypeOf(useCachedQuery(empty)).toEqualTypeOf<Result | undefined>();
|
|
83
|
+
useCachedQuery(query, "skip");
|
|
84
|
+
useCachedQuery(empty, "skip");
|
|
85
|
+
// @ts-expect-error Required query arguments cannot be omitted.
|
|
86
|
+
useCachedQuery(query);
|
|
87
|
+
// @ts-expect-error Argument types are preserved.
|
|
88
|
+
useCachedQuery(query, { id: 1 });
|
|
89
|
+
// @ts-expect-error Mutation references are not query references.
|
|
90
|
+
useCachedQuery(mutation, { id: "one" });
|
|
91
|
+
// @ts-expect-error Empty queries reject extra arguments.
|
|
92
|
+
useCachedQuery(empty, { id: "one" });
|
|
93
|
+
|
|
94
|
+
useCachedQueries({ first: { query, args: { id: "one" } } });
|
|
95
|
+
const status = useCachedQueryWithStatus(query, { id: "one" });
|
|
96
|
+
if (status.isSuccess) {
|
|
97
|
+
expectTypeOf(status.data).toEqualTypeOf<Result>();
|
|
98
|
+
}
|
|
99
|
+
expectTypeOf(useQuery(empty).data).toEqualTypeOf<Result | undefined>();
|
|
100
|
+
useQuery(query, "skip");
|
|
101
|
+
// @ts-expect-error Status queries also require their arguments.
|
|
102
|
+
useQuery(query);
|
|
103
|
+
// @ts-expect-error Status queries retain argument checking.
|
|
104
|
+
useCachedQueryWithStatus(query, { id: 1 });
|
|
105
|
+
}).toBeFunction();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("paginated hooks preserve the SDK's reference and result signatures", () => {
|
|
109
|
+
// Convex 1.46's paginated hooks still take a plain FunctionReference.
|
|
110
|
+
expectTypeOf(usePaginatedQuery).toExtend<typeof usePaginatedQueryCore>();
|
|
111
|
+
expectTypeOf(useCachedPaginatedQuery).toExtend<
|
|
112
|
+
typeof usePaginatedQueryCore
|
|
113
|
+
>();
|
|
114
|
+
type PaginatedQuery = FunctionReference<
|
|
115
|
+
"query",
|
|
116
|
+
"public",
|
|
117
|
+
{ channel: string; paginationOpts: PaginationOptions },
|
|
118
|
+
PaginationResult<Result>
|
|
119
|
+
>;
|
|
120
|
+
type SessionPaginatedQuery = FunctionReference<
|
|
121
|
+
"query",
|
|
122
|
+
"public",
|
|
123
|
+
{
|
|
124
|
+
sessionId: SessionId;
|
|
125
|
+
channel: string;
|
|
126
|
+
paginationOpts: PaginationOptions;
|
|
127
|
+
},
|
|
128
|
+
PaginationResult<Result>
|
|
129
|
+
>;
|
|
130
|
+
expectTypeOf((query: PaginatedQuery, sessionQuery: SessionPaginatedQuery) => {
|
|
131
|
+
expectTypeOf(
|
|
132
|
+
usePaginatedQuery(query, { channel: "one" }, { initialNumItems: 5 })
|
|
133
|
+
.results,
|
|
134
|
+
).toEqualTypeOf<Result[]>();
|
|
135
|
+
expectTypeOf(
|
|
136
|
+
useCachedPaginatedQuery(query, { channel: "one" }, { initialNumItems: 5 })
|
|
137
|
+
.results,
|
|
138
|
+
).toEqualTypeOf<Result[]>();
|
|
139
|
+
expectTypeOf(
|
|
140
|
+
useSessionPaginatedQuery(
|
|
141
|
+
sessionQuery,
|
|
142
|
+
{ channel: "one" },
|
|
143
|
+
{ initialNumItems: 5 },
|
|
144
|
+
)?.results,
|
|
145
|
+
).toEqualTypeOf<Result[] | undefined>();
|
|
146
|
+
usePaginatedQuery(query, "skip", { initialNumItems: 5 });
|
|
147
|
+
useCachedPaginatedQuery(query, "skip", { initialNumItems: 5 });
|
|
148
|
+
// @ts-expect-error Non-pagination arguments remain required.
|
|
149
|
+
usePaginatedQuery(query, {}, { initialNumItems: 5 });
|
|
150
|
+
// @ts-expect-error Non-pagination argument types are preserved.
|
|
151
|
+
useCachedPaginatedQuery(query, { channel: 1 }, { initialNumItems: 5 });
|
|
152
|
+
}).toBeFunction();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("client wrappers preserve future reference arguments and results", () => {
|
|
156
|
+
type InjectedQuery = FunctionReference_future<
|
|
157
|
+
"query",
|
|
158
|
+
"public",
|
|
159
|
+
{ injected: string; id: string },
|
|
160
|
+
Result
|
|
161
|
+
>;
|
|
162
|
+
type InjectedMutation = FunctionReference_future<
|
|
163
|
+
"mutation",
|
|
164
|
+
"public",
|
|
165
|
+
{ injected: string; id: string },
|
|
166
|
+
Result
|
|
167
|
+
>;
|
|
168
|
+
type InjectedAction = FunctionReference_future<
|
|
169
|
+
"action",
|
|
170
|
+
"public",
|
|
171
|
+
{ injected: string; id: string },
|
|
172
|
+
Result
|
|
173
|
+
>;
|
|
174
|
+
type OnlyInjected = FunctionReference_future<
|
|
175
|
+
"query",
|
|
176
|
+
"public",
|
|
177
|
+
{ injected: string },
|
|
178
|
+
Result
|
|
179
|
+
>;
|
|
180
|
+
expectTypeOf(
|
|
181
|
+
(
|
|
182
|
+
client: ConvexClient,
|
|
183
|
+
query: InjectedQuery,
|
|
184
|
+
mutation: InjectedMutation,
|
|
185
|
+
action: InjectedAction,
|
|
186
|
+
onlyInjected: OnlyInjected,
|
|
187
|
+
) => {
|
|
188
|
+
const injected = withArgs(client, { injected: "value" });
|
|
189
|
+
expectTypeOf(injected.query(query, { id: "one" })).toEqualTypeOf<
|
|
190
|
+
Promise<Result>
|
|
191
|
+
>();
|
|
192
|
+
expectTypeOf(injected.mutation(mutation, { id: "one" })).toEqualTypeOf<
|
|
193
|
+
Promise<Result>
|
|
194
|
+
>();
|
|
195
|
+
expectTypeOf(injected.action(action, { id: "one" })).toEqualTypeOf<
|
|
196
|
+
Promise<Result>
|
|
197
|
+
>();
|
|
198
|
+
expectTypeOf(injected.query(onlyInjected)).toEqualTypeOf<
|
|
199
|
+
Promise<Result>
|
|
200
|
+
>();
|
|
201
|
+
// @ts-expect-error Non-injected arguments remain required.
|
|
202
|
+
void injected.query(query);
|
|
203
|
+
// @ts-expect-error Non-injected argument types are preserved.
|
|
204
|
+
void injected.mutation(mutation, { id: 1 });
|
|
205
|
+
// @ts-expect-error Function kinds are preserved.
|
|
206
|
+
void injected.action(mutation, { id: "one" });
|
|
207
|
+
},
|
|
208
|
+
).toBeFunction();
|
|
209
|
+
expectTypeOf(
|
|
210
|
+
(
|
|
211
|
+
helper: ConvexTestingHelper,
|
|
212
|
+
query: Query,
|
|
213
|
+
mutation: Mutation,
|
|
214
|
+
action: Action,
|
|
215
|
+
) => {
|
|
216
|
+
expectTypeOf(helper.query(query, { id: "one" })).toEqualTypeOf<
|
|
217
|
+
Promise<Result>
|
|
218
|
+
>();
|
|
219
|
+
expectTypeOf(helper.mutation(mutation, { id: "one" })).toEqualTypeOf<
|
|
220
|
+
Promise<Result>
|
|
221
|
+
>();
|
|
222
|
+
expectTypeOf(helper.action(action, { id: "one" })).toEqualTypeOf<
|
|
223
|
+
Promise<Result>
|
|
224
|
+
>();
|
|
225
|
+
// @ts-expect-error Argument types are preserved by testing helpers.
|
|
226
|
+
void helper.query(query, { id: 1 });
|
|
227
|
+
},
|
|
228
|
+
).toBeFunction();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("session wrappers accept future references without losing injected argument types", () => {
|
|
232
|
+
type SessionQuery = FunctionReference_future<
|
|
233
|
+
"query",
|
|
234
|
+
"public",
|
|
235
|
+
{ sessionId: SessionId | null; id: string },
|
|
236
|
+
Result
|
|
237
|
+
>;
|
|
238
|
+
type SessionMutation = FunctionReference_future<
|
|
239
|
+
"mutation",
|
|
240
|
+
"public",
|
|
241
|
+
{ sessionId: SessionId; id: string },
|
|
242
|
+
Result
|
|
243
|
+
>;
|
|
244
|
+
type SessionAction = FunctionReference_future<
|
|
245
|
+
"action",
|
|
246
|
+
"public",
|
|
247
|
+
{ sessionId: SessionId; id: string },
|
|
248
|
+
Result
|
|
249
|
+
>;
|
|
250
|
+
type OnlySession = FunctionReference_future<
|
|
251
|
+
"query",
|
|
252
|
+
"public",
|
|
253
|
+
{ sessionId: SessionId },
|
|
254
|
+
Result
|
|
255
|
+
>;
|
|
256
|
+
type OptionalSessionQuery = FunctionReference_future<
|
|
257
|
+
"query",
|
|
258
|
+
"public",
|
|
259
|
+
{ sessionId: SessionId; id?: string },
|
|
260
|
+
Result
|
|
261
|
+
>;
|
|
262
|
+
expectTypeOf(
|
|
263
|
+
(
|
|
264
|
+
query: SessionQuery,
|
|
265
|
+
mutation: SessionMutation,
|
|
266
|
+
action: SessionAction,
|
|
267
|
+
onlySession: OnlySession,
|
|
268
|
+
optional: OptionalSessionQuery,
|
|
269
|
+
client: ConvexReactSessionClient,
|
|
270
|
+
ctx: GenericActionCtx<GenericDataModel>,
|
|
271
|
+
sessionId: SessionId,
|
|
272
|
+
) => {
|
|
273
|
+
expectTypeOf(useSessionQuery(query, { id: "one" })).toEqualTypeOf<
|
|
274
|
+
Result | undefined
|
|
275
|
+
>();
|
|
276
|
+
expectTypeOf(useSessionQuery(onlySession)).toEqualTypeOf<
|
|
277
|
+
Result | undefined
|
|
278
|
+
>();
|
|
279
|
+
expectTypeOf(useSessionQuery(optional)).toEqualTypeOf<
|
|
280
|
+
Result | undefined
|
|
281
|
+
>();
|
|
282
|
+
useSessionQuery(query, "skip");
|
|
283
|
+
expectTypeOf(useSessionMutation(mutation)({ id: "one" })).toEqualTypeOf<
|
|
284
|
+
Promise<Result>
|
|
285
|
+
>();
|
|
286
|
+
expectTypeOf(useSessionAction(action)({ id: "one" })).toEqualTypeOf<
|
|
287
|
+
Promise<Result>
|
|
288
|
+
>();
|
|
289
|
+
useSessionMutation(mutation).withOptimisticUpdate((_store, args) => {
|
|
290
|
+
expectTypeOf(args).toEqualTypeOf<{
|
|
291
|
+
sessionId: SessionId;
|
|
292
|
+
id: string;
|
|
293
|
+
}>();
|
|
294
|
+
});
|
|
295
|
+
expectTypeOf(client.sessionQuery(query, { id: "one" })).toEqualTypeOf<
|
|
296
|
+
Promise<Result>
|
|
297
|
+
>();
|
|
298
|
+
expectTypeOf(client.sessionQuery(onlySession)).toEqualTypeOf<
|
|
299
|
+
Promise<Result>
|
|
300
|
+
>();
|
|
301
|
+
expectTypeOf(
|
|
302
|
+
client.sessionMutation(mutation, { id: "one" }),
|
|
303
|
+
).toEqualTypeOf<Promise<Result>>();
|
|
304
|
+
expectTypeOf(client.sessionAction(action, { id: "one" })).toEqualTypeOf<
|
|
305
|
+
Promise<Result>
|
|
306
|
+
>();
|
|
307
|
+
const session = runSessionFunctions(ctx, sessionId);
|
|
308
|
+
expectTypeOf(session.runSessionQuery(query, { id: "one" })).toEqualTypeOf<
|
|
309
|
+
Promise<Result>
|
|
310
|
+
>();
|
|
311
|
+
expectTypeOf(
|
|
312
|
+
session.runSessionMutation(mutation, { id: "one" }),
|
|
313
|
+
).toEqualTypeOf<Promise<Result>>();
|
|
314
|
+
expectTypeOf(
|
|
315
|
+
session.runSessionAction(action, { id: "one" }),
|
|
316
|
+
).toEqualTypeOf<Promise<Result>>();
|
|
317
|
+
// @ts-expect-error Non-session arguments remain required.
|
|
318
|
+
useSessionQuery(query);
|
|
319
|
+
// @ts-expect-error Argument types are preserved.
|
|
320
|
+
void client.sessionMutation(mutation, { id: 1 });
|
|
321
|
+
// @ts-expect-error Session IDs are supplied by the wrapper.
|
|
322
|
+
void session.runSessionQuery(query, { id: "one", sessionId });
|
|
323
|
+
},
|
|
324
|
+
).toBeFunction();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("migration and retry helpers accept future references", () => {
|
|
328
|
+
type MigrationArgs = FunctionArgs<Parameters<typeof startMigration>[1]>;
|
|
329
|
+
type Migration = FunctionReference_future<
|
|
330
|
+
"mutation",
|
|
331
|
+
"internal",
|
|
332
|
+
MigrationArgs
|
|
333
|
+
>;
|
|
334
|
+
type RetryAction = FunctionReference_future<
|
|
335
|
+
"action",
|
|
336
|
+
"internal",
|
|
337
|
+
{ id: string },
|
|
338
|
+
null
|
|
339
|
+
>;
|
|
340
|
+
expectTypeOf(
|
|
341
|
+
(
|
|
342
|
+
ctx: GenericActionCtx<GenericDataModel>,
|
|
343
|
+
scheduler: Scheduler,
|
|
344
|
+
migration: Migration,
|
|
345
|
+
action: RetryAction,
|
|
346
|
+
) => {
|
|
347
|
+
void startMigration({ scheduler }, migration);
|
|
348
|
+
void startMigrationsSerially({ scheduler }, [migration]);
|
|
349
|
+
const { runWithRetries } = makeActionRetrier("test:retry");
|
|
350
|
+
void runWithRetries(ctx, action, { id: "one" });
|
|
351
|
+
// @ts-expect-error Retry arguments retain their types.
|
|
352
|
+
void runWithRetries(ctx, action, { id: 1 });
|
|
353
|
+
},
|
|
354
|
+
).toBeFunction();
|
|
355
|
+
expectTypeOf<Migration[]>().toExtend<
|
|
356
|
+
NonNullable<Parameters<typeof getStatus>[1]["migrations"]>
|
|
357
|
+
>();
|
|
358
|
+
expectTypeOf<Migration>().toExtend<Parameters<typeof cancelMigration>[2]>();
|
|
359
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "convex-helpers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.125",
|
|
4
4
|
"description": "A collection of useful code to complement the official convex package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"homepage": "https://github.com/get-convex/convex-helpers/tree/main/packages/convex-helpers/README.md",
|
|
165
165
|
"peerDependencies": {
|
|
166
166
|
"@standard-schema/spec": "^1.0.0",
|
|
167
|
-
"convex": "^1.
|
|
167
|
+
"convex": "^1.46.0",
|
|
168
168
|
"hono": "^4.0.5",
|
|
169
169
|
"react": "^17.0.2 || ^18.0.0 || ^19.0.0",
|
|
170
170
|
"typescript": "^5.5 || ^6.0.0 || ^7.0.0",
|
package/react/cache/hooks.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { OptionalRestArgsOrSkip, PaginatedQueryArgs, PaginatedQueryReference,
|
|
2
|
-
import
|
|
1
|
+
import type { OptionalRestArgsOrSkip, PaginatedQueryArgs, PaginatedQueryReference, UsePaginatedQueryReturnType } from "convex/react";
|
|
2
|
+
import { useQueries as useQueriesCore } from "convex/react";
|
|
3
|
+
import type { FunctionReference, FunctionReference_future, FunctionReturnType } from "convex/server";
|
|
3
4
|
/**
|
|
4
5
|
* Load a variable number of reactive Convex queries, utilizing
|
|
5
6
|
* the query cache.
|
|
@@ -52,7 +53,7 @@ import type { FunctionReference, FunctionReturnType } from "convex/server";
|
|
|
52
53
|
*
|
|
53
54
|
* @public
|
|
54
55
|
*/
|
|
55
|
-
export declare function useQueries(queries:
|
|
56
|
+
export declare function useQueries(queries: Record<string, Pick<Parameters<typeof useQueriesCore>[0][string], "query" | "args">>): Record<string, any | undefined | Error>;
|
|
56
57
|
/**
|
|
57
58
|
* Load a reactive query within a React component.
|
|
58
59
|
*
|
|
@@ -69,7 +70,7 @@ export declare function useQueries(queries: RequestForQueries): Record<string, a
|
|
|
69
70
|
*
|
|
70
71
|
* @public
|
|
71
72
|
*/
|
|
72
|
-
export declare function useQuery<Query extends FunctionReference<"query">>(query: Query, ...queryArgs: OptionalRestArgsOrSkip<Query>): FunctionReturnType<Query> | undefined;
|
|
73
|
+
export declare function useQuery<Query extends FunctionReference<"query"> | FunctionReference_future<"query">>(query: Query, ...queryArgs: OptionalRestArgsOrSkip<Query>): FunctionReturnType<Query> | undefined;
|
|
73
74
|
/**
|
|
74
75
|
* Load data reactively from a paginated query to a create a growing list.
|
|
75
76
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAIL,UAAU,IAAI,cAAc,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAEV,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAGnB,MAAM,eAAe,CAAC;AAkBvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,UAAU,CAExB,OAAO,EAAE,MAAM,CACb,MAAM,EACN,IAAI,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,CACrE,GACA,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,GAAG,KAAK,CAAC,CAgCzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CACtB,KAAK,SAAS,iBAAiB,CAAC,OAAO,CAAC,GAAG,wBAAwB,CAAC,OAAO,CAAC,EAE5E,KAAK,EAAE,KAAK,EACZ,GAAG,SAAS,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAC1C,kBAAkB,CAAC,KAAK,CAAC,GAAG,SAAS,CAoBvC;AAmHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,uBAAuB,EACrE,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,MAAM,EACxC,OAAO,EAAE;IACP,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GACA,2BAA2B,CAAC,KAAK,CAAC,CA4PpC"}
|
package/react/cache/hooks.js
CHANGED
|
@@ -61,7 +61,9 @@ const uuid = typeof crypto !== "undefined" && crypto.randomUUID
|
|
|
61
61
|
*
|
|
62
62
|
* @public
|
|
63
63
|
*/
|
|
64
|
-
export function useQueries(
|
|
64
|
+
export function useQueries(
|
|
65
|
+
// Follow the SDK's reference types, excluding its internal pagination options.
|
|
66
|
+
queries) {
|
|
65
67
|
const { registry } = useContext(ConvexQueryCacheContext);
|
|
66
68
|
if (registry === null) {
|
|
67
69
|
throw new Error("Could not find `ConvexQueryCacheContext`! This `useQuery` implementation must be used in the React component " +
|
package/react/cache/hooks.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type {
|
|
|
2
2
|
OptionalRestArgsOrSkip,
|
|
3
3
|
PaginatedQueryArgs,
|
|
4
4
|
PaginatedQueryReference,
|
|
5
|
-
RequestForQueries,
|
|
6
5
|
UsePaginatedQueryReturnType,
|
|
7
6
|
} from "convex/react";
|
|
8
7
|
import {
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
import type {
|
|
15
14
|
FunctionArgs,
|
|
16
15
|
FunctionReference,
|
|
16
|
+
FunctionReference_future,
|
|
17
17
|
FunctionReturnType,
|
|
18
18
|
paginationOptsValidator,
|
|
19
19
|
PaginationResult,
|
|
@@ -88,7 +88,11 @@ const uuid =
|
|
|
88
88
|
* @public
|
|
89
89
|
*/
|
|
90
90
|
export function useQueries(
|
|
91
|
-
|
|
91
|
+
// Follow the SDK's reference types, excluding its internal pagination options.
|
|
92
|
+
queries: Record<
|
|
93
|
+
string,
|
|
94
|
+
Pick<Parameters<typeof useQueriesCore>[0][string], "query" | "args">
|
|
95
|
+
>,
|
|
92
96
|
): Record<string, any | undefined | Error> {
|
|
93
97
|
const { registry } = useContext(ConvexQueryCacheContext);
|
|
94
98
|
if (registry === null) {
|
|
@@ -139,7 +143,9 @@ export function useQueries(
|
|
|
139
143
|
*
|
|
140
144
|
* @public
|
|
141
145
|
*/
|
|
142
|
-
export function useQuery<
|
|
146
|
+
export function useQuery<
|
|
147
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
148
|
+
>(
|
|
143
149
|
query: Query,
|
|
144
150
|
...queryArgs: OptionalRestArgsOrSkip<Query>
|
|
145
151
|
): FunctionReturnType<Query> | undefined {
|
|
@@ -170,10 +176,9 @@ export function useQuery<Query extends FunctionReference<"query">>(
|
|
|
170
176
|
* @param args Arguments to the function, like { foo: "bar" }
|
|
171
177
|
* @returns A string key that uniquely identifies the query and its arguments.
|
|
172
178
|
*/
|
|
173
|
-
function createQueryKey<
|
|
174
|
-
query
|
|
175
|
-
|
|
176
|
-
): string {
|
|
179
|
+
function createQueryKey<
|
|
180
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
181
|
+
>(query: Query, args: FunctionArgs<Query>): string {
|
|
177
182
|
const queryString = getFunctionName(query);
|
|
178
183
|
const key = [queryString, convexToJson(args)];
|
|
179
184
|
const queryKey = JSON.stringify(key);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConvexReactClient } from "convex/react";
|
|
2
|
-
import type { FunctionArgs, FunctionReference } from "convex/server";
|
|
2
|
+
import type { FunctionArgs, FunctionReference, FunctionReference_future } from "convex/server";
|
|
3
3
|
import type { FC, PropsWithChildren } from "react";
|
|
4
4
|
export declare const ConvexQueryCacheContext: import("react").Context<{
|
|
5
5
|
registry: CacheRegistry | null;
|
|
@@ -54,7 +54,7 @@ declare class CacheRegistry {
|
|
|
54
54
|
maxIdleEntries: number;
|
|
55
55
|
idle: number;
|
|
56
56
|
constructor(convex: ConvexReactClient, options: ConvexQueryCacheOptions);
|
|
57
|
-
start<Query extends FunctionReference<"query">>(id: string, queryKey: string, query: Query, args: FunctionArgs<Query>): void;
|
|
57
|
+
start<Query extends FunctionReference<"query"> | FunctionReference_future<"query">>(id: string, queryKey: string, query: Query, args: FunctionArgs<Query>): void;
|
|
58
58
|
end(id: string): void;
|
|
59
59
|
debug(): void;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["provider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,
|
|
1
|
+
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KAAK,SACH,iBAAiB,CAAC,OAAO,CAAC,GAAG,wBAAwB,CAAC,OAAO,CAAC,EAEhE,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,GACxB,IAAI,CAiBN;IAED,GAAG,CAAC,EAAE,EAAE,MAAM,QAwBb;IACD,KAAK,SAYJ;CACF"}
|
package/react/cache/provider.tsx
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useConvex, ConvexReactClient } from "convex/react";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
FunctionArgs,
|
|
5
|
+
FunctionReference,
|
|
6
|
+
FunctionReference_future,
|
|
7
|
+
} from "convex/server";
|
|
4
8
|
import type { FC, PropsWithChildren } from "react";
|
|
5
9
|
import { createContext, useMemo } from "react";
|
|
6
10
|
|
|
@@ -109,7 +113,10 @@ class CacheRegistry {
|
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
// Enable a new subscription.
|
|
112
|
-
start<
|
|
116
|
+
start<
|
|
117
|
+
Query extends
|
|
118
|
+
FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
119
|
+
>(
|
|
113
120
|
id: string,
|
|
114
121
|
queryKey: string,
|
|
115
122
|
query: Query,
|
package/react/sessions.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* for more information.
|
|
17
17
|
*/
|
|
18
18
|
import React from "react";
|
|
19
|
-
import type { FunctionArgs, FunctionReference, FunctionReturnType, PaginationOptions, PaginationResult } from "convex/server";
|
|
19
|
+
import type { FunctionArgs, FunctionReference, FunctionReference_future, FunctionReturnType, PaginationOptions, PaginationResult } from "convex/server";
|
|
20
20
|
import { ConvexReactClient, type ConvexReactClientOptions, type MutationOptions, type PaginatedQueryArgs, type UsePaginatedQueryReturnType } from "convex/react";
|
|
21
21
|
import type { SessionId } from "../server/sessions.js";
|
|
22
22
|
import type { EmptyObject, BetterOmit } from "../index.js";
|
|
@@ -26,6 +26,8 @@ export type UseStorage<T> = (key: string, initialValue: T) => readonly [T, (valu
|
|
|
26
26
|
export type RefreshSessionFn = (beforeUpdate?: (newSessionId: SessionId) => any | Promise<any>) => Promise<SessionId>;
|
|
27
27
|
type SessionFunction<T extends "query" | "mutation" | "action", Args = any> = FunctionReference<T, "public", {
|
|
28
28
|
sessionId: SessionId;
|
|
29
|
+
} & Args> | FunctionReference_future<T, "public", {
|
|
30
|
+
sessionId: SessionId;
|
|
29
31
|
} & Args>;
|
|
30
32
|
type ArgsWithoutSession<Fn extends SessionFunction<"query" | "mutation" | "action">> = BetterOmit<FunctionArgs<Fn>, "sessionId">;
|
|
31
33
|
export type SessionQueryArgsArray<Fn extends SessionFunction<"query">> = keyof FunctionArgs<Fn> extends "sessionId" ? [args?: EmptyObject | "skip"] : Partial<ArgsWithoutSession<Fn>> extends ArgsWithoutSession<Fn> ? [args?: ArgsWithoutSession<Fn> | "skip"] : [args: ArgsWithoutSession<Fn> | "skip"];
|
|
@@ -90,8 +92,8 @@ export declare function useSessionQuery<Query extends SessionFunction<"query">>(
|
|
|
90
92
|
export declare function useSessionPaginatedQuery<Query extends SessionPaginatedQueryFunction>(query: Query, args: SessionPaginatedQueryArgs<Query>, options: {
|
|
91
93
|
initialNumItems: number;
|
|
92
94
|
}): UsePaginatedQueryReturnType<Query> | undefined;
|
|
93
|
-
type SessionMutation<Mutation extends FunctionReference<"mutation">> = (...args: SessionArgsArray<Mutation>) => Promise<FunctionReturnType<Mutation>>;
|
|
94
|
-
interface ReactSessionMutation<Mutation extends FunctionReference<"mutation">> extends SessionMutation<Mutation> {
|
|
95
|
+
type SessionMutation<Mutation extends FunctionReference<"mutation"> | FunctionReference_future<"mutation">> = (...args: SessionArgsArray<Mutation>) => Promise<FunctionReturnType<Mutation>>;
|
|
96
|
+
interface ReactSessionMutation<Mutation extends FunctionReference<"mutation"> | FunctionReference_future<"mutation">> extends SessionMutation<Mutation> {
|
|
95
97
|
withOptimisticUpdate(optimisticUpdate: OptimisticUpdate<FunctionArgs<Mutation>>): SessionMutation<Mutation>;
|
|
96
98
|
}
|
|
97
99
|
/**
|
package/react/sessions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["sessions.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAIL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EAIpB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EACjC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAC1B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,KAEb,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAChC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,CAC7B,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAC3D,OAAO,CAAC,SAAS,CAAC,CAAC;AASxB,KAAK,eAAe,
|
|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,CAAC,QAAQ,CAAC,CAAC,CACxC,GACA,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CASvC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,MAAM,SAAS,eAAe,CAAC,QAAQ,CAAC,EACpD,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAChC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAKrC;CACF"}
|
package/react/sessions.ts
CHANGED
|
@@ -26,6 +26,7 @@ import React, {
|
|
|
26
26
|
import type {
|
|
27
27
|
FunctionArgs,
|
|
28
28
|
FunctionReference,
|
|
29
|
+
FunctionReference_future,
|
|
29
30
|
FunctionReturnType,
|
|
30
31
|
PaginationOptions,
|
|
31
32
|
PaginationResult,
|
|
@@ -67,10 +68,9 @@ const SessionContext = React.createContext<{
|
|
|
67
68
|
ssrFriendly?: boolean;
|
|
68
69
|
} | null>(null);
|
|
69
70
|
|
|
70
|
-
type SessionFunction<
|
|
71
|
-
T
|
|
72
|
-
|
|
73
|
-
> = FunctionReference<T, "public", { sessionId: SessionId } & Args>;
|
|
71
|
+
type SessionFunction<T extends "query" | "mutation" | "action", Args = any> =
|
|
72
|
+
| FunctionReference<T, "public", { sessionId: SessionId } & Args>
|
|
73
|
+
| FunctionReference_future<T, "public", { sessionId: SessionId } & Args>;
|
|
74
74
|
|
|
75
75
|
type ArgsWithoutSession<
|
|
76
76
|
Fn extends SessionFunction<"query" | "mutation" | "action">,
|
|
@@ -258,13 +258,17 @@ export function useSessionPaginatedQuery<
|
|
|
258
258
|
return usePaginatedQuery(query, argsObject, options);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
type SessionMutation<
|
|
261
|
+
type SessionMutation<
|
|
262
|
+
Mutation extends
|
|
263
|
+
FunctionReference<"mutation"> | FunctionReference_future<"mutation">,
|
|
264
|
+
> = (
|
|
262
265
|
...args: SessionArgsArray<Mutation>
|
|
263
266
|
) => Promise<FunctionReturnType<Mutation>>;
|
|
264
267
|
|
|
265
268
|
// Similar to ReactMutation, but with a sessionId parameter.
|
|
266
269
|
interface ReactSessionMutation<
|
|
267
|
-
Mutation extends
|
|
270
|
+
Mutation extends
|
|
271
|
+
FunctionReference<"mutation"> | FunctionReference_future<"mutation">,
|
|
268
272
|
> extends SessionMutation<Mutation> {
|
|
269
273
|
withOptimisticUpdate(
|
|
270
274
|
optimisticUpdate: OptimisticUpdate<FunctionArgs<Mutation>>,
|
package/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OptionalRestArgsOrSkip, PaginatedQueryArgs, PaginatedQueryReference, UsePaginatedQueryReturnType } from "convex/react";
|
|
2
2
|
import { useQueries } from "convex/react";
|
|
3
|
-
import type { FunctionReference, FunctionReturnType } from "convex/server";
|
|
3
|
+
import type { FunctionReference, FunctionReference_future, FunctionReturnType } from "convex/server";
|
|
4
4
|
/**
|
|
5
5
|
* Use in place of `useQuery` from "convex/react" to fetch data from a query
|
|
6
6
|
* function but instead returns `{ status, data, error, isSuccess, isPending, isError}`.
|
|
@@ -34,7 +34,7 @@ import type { FunctionReference, FunctionReturnType } from "convex/server";
|
|
|
34
34
|
* - `isPending` is `true` if the query is still loading or "skip" was passed.
|
|
35
35
|
* - `isError` is `true` if the query threw an exception.
|
|
36
36
|
*/
|
|
37
|
-
export declare const useQuery: <Query extends FunctionReference<"query">>(query: Query, ...queryArgs: OptionalRestArgsOrSkip<Query>) => {
|
|
37
|
+
export declare const useQuery: <Query extends FunctionReference<"query"> | FunctionReference_future<"query">>(query: Query, ...queryArgs: OptionalRestArgsOrSkip<Query>) => {
|
|
38
38
|
status: "success";
|
|
39
39
|
data: FunctionReturnType<Query>;
|
|
40
40
|
error: undefined;
|
|
@@ -95,7 +95,7 @@ export declare const useQuery: <Query extends FunctionReference<"query">>(query:
|
|
|
95
95
|
* @returns
|
|
96
96
|
* @returns A useQuery function that returns an object with status, data, error, isSuccess, isPending, isError.
|
|
97
97
|
*/
|
|
98
|
-
export declare function makeUseQueryWithStatus(useQueriesHook: typeof useQueries): <Query extends FunctionReference<"query">>(query: Query, ...queryArgs: OptionalRestArgsOrSkip<Query>) => {
|
|
98
|
+
export declare function makeUseQueryWithStatus(useQueriesHook: typeof useQueries): <Query extends FunctionReference<"query"> | FunctionReference_future<"query">>(query: Query, ...queryArgs: OptionalRestArgsOrSkip<Query>) => {
|
|
99
99
|
status: "success";
|
|
100
100
|
data: FunctionReturnType<Query>;
|
|
101
101
|
error: undefined;
|
package/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,UAAU,EAGX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAOvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,UAAU,EAGX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAOvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,QAAQ,GA2CjB,KAAK,SACH,iBAAiB,CAAC,OAAO,CAAC,GAAG,wBAAwB,CAAC,OAAO,CAAC,SAEzD,KAAK,gBACE,sBAAsB,CAAC,KAA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KAAK,CAAC;CAChB,GACD;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;CACf,CAsDN;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,uBAAuB,EACrE,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,MAAM,EACxC,OAAO,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GACnC,2BAA2B,CAAC,KAAK,CAAC,CA8OpC"}
|
package/react.test.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { cleanup, renderHook } from "@testing-library/react";
|
|
3
|
+
import { createElement, type ReactNode } from "react";
|
|
4
|
+
import { afterEach, expect, expectTypeOf, test, vi } from "vitest";
|
|
5
|
+
import { ConvexProvider, type ConvexReactClient } from "convex/react";
|
|
6
|
+
import {
|
|
7
|
+
makeFunctionReference,
|
|
8
|
+
type FunctionReference_future,
|
|
9
|
+
} from "convex/server";
|
|
10
|
+
import { makeUseQueryWithStatus } from "./react.js";
|
|
11
|
+
import { useQuery, useQueries } from "./react/cache/hooks.js";
|
|
12
|
+
import { ConvexQueryCacheProvider } from "./react/cache/provider.js";
|
|
13
|
+
|
|
14
|
+
afterEach(cleanup);
|
|
15
|
+
|
|
16
|
+
const query = makeFunctionReference<"query", { id: string }, string>(
|
|
17
|
+
"test:query",
|
|
18
|
+
);
|
|
19
|
+
const futureQuery: FunctionReference_future<
|
|
20
|
+
"query",
|
|
21
|
+
"public",
|
|
22
|
+
{ id: string },
|
|
23
|
+
string
|
|
24
|
+
> = query;
|
|
25
|
+
|
|
26
|
+
function setup(value: string | undefined | Error) {
|
|
27
|
+
const unsubscribe = vi.fn();
|
|
28
|
+
const watchQuery = vi.fn(() => ({
|
|
29
|
+
localQueryResult: () => {
|
|
30
|
+
if (value instanceof Error) throw value;
|
|
31
|
+
return value;
|
|
32
|
+
},
|
|
33
|
+
onUpdate: () => unsubscribe,
|
|
34
|
+
journal: () => undefined,
|
|
35
|
+
}));
|
|
36
|
+
const client = { watchQuery } as unknown as ConvexReactClient;
|
|
37
|
+
const wrapper = ({ children }: { children: ReactNode }) =>
|
|
38
|
+
createElement(
|
|
39
|
+
ConvexProvider,
|
|
40
|
+
{ client },
|
|
41
|
+
createElement(ConvexQueryCacheProvider, { maxIdleEntries: 0 }, children),
|
|
42
|
+
);
|
|
43
|
+
return { wrapper, watchQuery, unsubscribe };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
test.each([
|
|
47
|
+
["plain", query],
|
|
48
|
+
["future", futureQuery],
|
|
49
|
+
] as const)(
|
|
50
|
+
"cached useQuery subscribes with a %s reference",
|
|
51
|
+
(_name, reference) => {
|
|
52
|
+
const { wrapper, watchQuery, unsubscribe } = setup("found");
|
|
53
|
+
const { result, unmount } = renderHook(
|
|
54
|
+
() => useQuery(reference, { id: "one" }),
|
|
55
|
+
{ wrapper },
|
|
56
|
+
);
|
|
57
|
+
expectTypeOf(result.current).toEqualTypeOf<string | undefined>();
|
|
58
|
+
expect(result.current).toBe("found");
|
|
59
|
+
expect(watchQuery).toHaveBeenCalledWith(reference, { id: "one" });
|
|
60
|
+
expect(unsubscribe).not.toHaveBeenCalled();
|
|
61
|
+
unmount();
|
|
62
|
+
expect(unsubscribe).toHaveBeenCalled();
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
test("cached useQueries composes with makeUseQueryWithStatus for future references", () => {
|
|
67
|
+
const { wrapper } = setup("found");
|
|
68
|
+
const useQueryWithStatus = makeUseQueryWithStatus(useQueries);
|
|
69
|
+
const { result } = renderHook(
|
|
70
|
+
() => useQueryWithStatus(futureQuery, { id: "one" }),
|
|
71
|
+
{ wrapper },
|
|
72
|
+
);
|
|
73
|
+
expectTypeOf(result.current.data).toEqualTypeOf<string | undefined>();
|
|
74
|
+
expect(result.current).toEqual({
|
|
75
|
+
status: "success",
|
|
76
|
+
data: "found",
|
|
77
|
+
error: undefined,
|
|
78
|
+
isSuccess: true,
|
|
79
|
+
isPending: false,
|
|
80
|
+
isError: false,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test.each([undefined, new Error("query failed")])(
|
|
85
|
+
"cached status queries preserve pending and error results: %s",
|
|
86
|
+
(value) => {
|
|
87
|
+
const { wrapper } = setup(value);
|
|
88
|
+
const useQueryWithStatus = makeUseQueryWithStatus(useQueries);
|
|
89
|
+
const { result } = renderHook(
|
|
90
|
+
() => useQueryWithStatus(futureQuery, { id: "one" }),
|
|
91
|
+
{ wrapper },
|
|
92
|
+
);
|
|
93
|
+
expect(result.current.status).toBe(
|
|
94
|
+
value === undefined ? "pending" : "error",
|
|
95
|
+
);
|
|
96
|
+
expect(result.current.data).toBeUndefined();
|
|
97
|
+
expect(result.current.error).toBe(value);
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
test("skipped future references do not open cached subscriptions", () => {
|
|
102
|
+
const { wrapper, watchQuery } = setup("found");
|
|
103
|
+
const useQueryWithStatus = makeUseQueryWithStatus(useQueries);
|
|
104
|
+
const { result } = renderHook(
|
|
105
|
+
() => ({
|
|
106
|
+
cached: useQuery(futureQuery, "skip"),
|
|
107
|
+
status: useQueryWithStatus(futureQuery, "skip"),
|
|
108
|
+
}),
|
|
109
|
+
{ wrapper },
|
|
110
|
+
);
|
|
111
|
+
expect(result.current.cached).toBeUndefined();
|
|
112
|
+
expect(result.current.status.status).toBe("pending");
|
|
113
|
+
expect(watchQuery).not.toHaveBeenCalled();
|
|
114
|
+
});
|
package/react.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "convex/react";
|
|
15
15
|
import type {
|
|
16
16
|
FunctionReference,
|
|
17
|
+
FunctionReference_future,
|
|
17
18
|
FunctionReturnType,
|
|
18
19
|
PaginationOptions,
|
|
19
20
|
paginationOptsValidator,
|
|
@@ -100,7 +101,10 @@ export const useQuery = makeUseQueryWithStatus(useQueries);
|
|
|
100
101
|
* @returns A useQuery function that returns an object with status, data, error, isSuccess, isPending, isError.
|
|
101
102
|
*/
|
|
102
103
|
export function makeUseQueryWithStatus(useQueriesHook: typeof useQueries) {
|
|
103
|
-
return function useQuery<
|
|
104
|
+
return function useQuery<
|
|
105
|
+
Query extends
|
|
106
|
+
FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
107
|
+
>(
|
|
104
108
|
query: Query,
|
|
105
109
|
...queryArgs: OptionalRestArgsOrSkip<Query>
|
|
106
110
|
):
|
package/server/migrations.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ npx convex run migrations --prod
|
|
|
92
92
|
* Ideas for the future:
|
|
93
93
|
* - Allow scheduling multiple batches at once. Maybe partition by time.
|
|
94
94
|
*/
|
|
95
|
-
import type { DocumentByInfo, DocumentByName, FunctionReference, GenericDatabaseReader, GenericDataModel, GenericMutationCtx, MutationBuilder, NamedTableInfo, OrderedQuery, QueryInitializer, RegisteredMutation, Scheduler, TableNamesInDataModel } from "convex/server";
|
|
95
|
+
import type { DocumentByInfo, DocumentByName, FunctionReference, FunctionReference_future, GenericDatabaseReader, GenericDataModel, GenericMutationCtx, MutationBuilder, NamedTableInfo, OrderedQuery, QueryInitializer, RegisteredMutation, Scheduler, TableNamesInDataModel } from "convex/server";
|
|
96
96
|
import type { GenericId, ObjectType } from "convex/values";
|
|
97
97
|
import type { ErrorMessage } from "../index.js";
|
|
98
98
|
export declare const DEFAULT_BATCH_SIZE = 100;
|
|
@@ -143,6 +143,7 @@ type MigrationArgs = ObjectType<typeof migrationArgs>;
|
|
|
143
143
|
type MigrationTableNames<DataModel extends GenericDataModel> = {
|
|
144
144
|
[K in TableNamesInDataModel<DataModel>]: DocumentByInfo<NamedTableInfo<DataModel, K>> extends MigrationMetadata ? K : ErrorMessage<"Add migrationsTable to your schema">;
|
|
145
145
|
}[TableNamesInDataModel<DataModel>];
|
|
146
|
+
type MigrationReference = FunctionReference<"mutation", "internal", MigrationArgs> | FunctionReference_future<"mutation", "internal", MigrationArgs>;
|
|
146
147
|
/**
|
|
147
148
|
* Makes the migration wrapper, with types for your own tables.
|
|
148
149
|
*
|
|
@@ -210,7 +211,7 @@ export declare function makeMigration<DataModel extends GenericDataModel, Migrat
|
|
|
210
211
|
*/
|
|
211
212
|
export declare function startMigration(ctx: {
|
|
212
213
|
scheduler: Scheduler;
|
|
213
|
-
}, fnRef:
|
|
214
|
+
}, fnRef: MigrationReference, opts?: {
|
|
214
215
|
startCursor?: string | null;
|
|
215
216
|
batchSize?: number;
|
|
216
217
|
dryRun?: boolean;
|
|
@@ -241,7 +242,7 @@ export declare function startMigration(ctx: {
|
|
|
241
242
|
*/
|
|
242
243
|
export declare function startMigrationsSerially(ctx: {
|
|
243
244
|
scheduler: Scheduler;
|
|
244
|
-
}, fnRefs:
|
|
245
|
+
}, fnRefs: MigrationReference[]): Promise<void>;
|
|
245
246
|
export type MigrationStatus<TableName extends string> = (MigrationMetadataDoc<TableName> | {
|
|
246
247
|
name: string;
|
|
247
248
|
status: "not found";
|
|
@@ -264,7 +265,7 @@ export declare function getStatus<DataModel extends GenericDataModel, MigrationT
|
|
|
264
265
|
db: GenericDatabaseReader<DataModel>;
|
|
265
266
|
}, { migrationTable, migrations, limit, }: {
|
|
266
267
|
migrationTable: MigrationTable;
|
|
267
|
-
migrations?:
|
|
268
|
+
migrations?: MigrationReference[];
|
|
268
269
|
limit?: number;
|
|
269
270
|
}): Promise<MigrationStatus<MigrationTable>[]>;
|
|
270
271
|
/**
|
|
@@ -279,7 +280,7 @@ export declare function getStatus<DataModel extends GenericDataModel, MigrationT
|
|
|
279
280
|
export declare function cancelMigration<DataModel extends GenericDataModel>(ctx: {
|
|
280
281
|
db: GenericDatabaseReader<DataModel>;
|
|
281
282
|
scheduler: Scheduler;
|
|
282
|
-
}, migrationTable: MigrationTableNames<DataModel>, migration:
|
|
283
|
+
}, migrationTable: MigrationTableNames<DataModel>, migration: MigrationReference | string): Promise<{
|
|
283
284
|
cursor: string | null;
|
|
284
285
|
isDone: boolean;
|
|
285
286
|
latestEnd?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EAErB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EAET,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAGtC,QAAA,MAAM,gBAAgB;IACpB,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IAER,SAAS;IACT,WAAW;IACX,SAAS;CACV,CAAC;AACF,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC7D,KAAK,oBAAoB,CAAC,SAAS,SAAS,MAAM,IAAI,iBAAiB,GAAG;IACxE,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AACF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;UAE1B,CAAC;AA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SAAS,gBAAgB,EAClC,cAAc,SAAS,mBAAmB,CAAC,SAAS,CAAC,EAErD,GAAG,EAAE;IAAE,EAAE,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAA;CAAE,EAC7C,EACE,cAAc,EACd,UAAU,EACV,KAAK,GACN,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,CAAC,CAkC5C;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,SAAS,SAAS,gBAAgB,EACtE,GAAG,EAAE;IAAE,EAAE,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,EACnE,cAAc,EAAE,mBAAmB,CAAC,SAAS,CAAC,EAC9C,SAAS,EAAE,kBAAkB,GAAG,MAAM;;;;;;;;;;;;;;;;;;;GA8BvC"}
|
package/server/migrations.ts
CHANGED
|
@@ -97,6 +97,7 @@ import type {
|
|
|
97
97
|
DocumentByInfo,
|
|
98
98
|
DocumentByName,
|
|
99
99
|
FunctionReference,
|
|
100
|
+
FunctionReference_future,
|
|
100
101
|
GenericDatabaseReader,
|
|
101
102
|
GenericDatabaseWriter,
|
|
102
103
|
GenericDataModel,
|
|
@@ -162,6 +163,10 @@ type MigrationTableNames<DataModel extends GenericDataModel> = {
|
|
|
162
163
|
: ErrorMessage<"Add migrationsTable to your schema">;
|
|
163
164
|
}[TableNamesInDataModel<DataModel>];
|
|
164
165
|
|
|
166
|
+
type MigrationReference =
|
|
167
|
+
| FunctionReference<"mutation", "internal", MigrationArgs>
|
|
168
|
+
| FunctionReference_future<"mutation", "internal", MigrationArgs>;
|
|
169
|
+
|
|
165
170
|
/**
|
|
166
171
|
* Makes the migration wrapper, with types for your own tables.
|
|
167
172
|
*
|
|
@@ -527,7 +532,7 @@ export function makeMigration<
|
|
|
527
532
|
*/
|
|
528
533
|
export async function startMigration(
|
|
529
534
|
ctx: { scheduler: Scheduler },
|
|
530
|
-
fnRef:
|
|
535
|
+
fnRef: MigrationReference,
|
|
531
536
|
opts?: {
|
|
532
537
|
startCursor?: string | null;
|
|
533
538
|
batchSize?: number;
|
|
@@ -569,7 +574,7 @@ export async function startMigration(
|
|
|
569
574
|
*/
|
|
570
575
|
export async function startMigrationsSerially(
|
|
571
576
|
ctx: { scheduler: Scheduler },
|
|
572
|
-
fnRefs:
|
|
577
|
+
fnRefs: MigrationReference[],
|
|
573
578
|
) {
|
|
574
579
|
if (fnRefs.length === 0) return;
|
|
575
580
|
const [fnRef, ...rest] = fnRefs;
|
|
@@ -608,7 +613,7 @@ export async function getStatus<
|
|
|
608
613
|
limit,
|
|
609
614
|
}: {
|
|
610
615
|
migrationTable: MigrationTable;
|
|
611
|
-
migrations?:
|
|
616
|
+
migrations?: MigrationReference[];
|
|
612
617
|
limit?: number;
|
|
613
618
|
},
|
|
614
619
|
): Promise<MigrationStatus<MigrationTable>[]> {
|
|
@@ -659,7 +664,7 @@ export async function getStatus<
|
|
|
659
664
|
export async function cancelMigration<DataModel extends GenericDataModel>(
|
|
660
665
|
ctx: { db: GenericDatabaseReader<DataModel>; scheduler: Scheduler },
|
|
661
666
|
migrationTable: MigrationTableNames<DataModel>,
|
|
662
|
-
migration:
|
|
667
|
+
migration: MigrationReference | string,
|
|
663
668
|
) {
|
|
664
669
|
const name =
|
|
665
670
|
typeof migration === "string" ? migration : getFunctionName(migration);
|
package/server/retries.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Convex action until it succeeds. An action should only be retried if it is
|
|
4
4
|
* safe to do so, i.e., if it's idempotent or doesn't have any unsafe side effects.
|
|
5
5
|
*/
|
|
6
|
-
import type { FunctionReference, FunctionVisibility, Scheduler, DefaultFunctionArgs } from "convex/server";
|
|
6
|
+
import type { FunctionReference, FunctionReference_future, FunctionVisibility, Scheduler, DefaultFunctionArgs } from "convex/server";
|
|
7
7
|
/**
|
|
8
8
|
* Create a function that retries an action with exponential backoff.
|
|
9
9
|
* e.g.
|
|
@@ -38,7 +38,7 @@ export declare function makeActionRetrier(retryFnName: string, options?: {
|
|
|
38
38
|
maxFailures?: number;
|
|
39
39
|
log?: (msg: string) => void;
|
|
40
40
|
}): {
|
|
41
|
-
runWithRetries: <Action extends FunctionReference<"action", Visibility, Args, null | Promise<null> | void | Promise<void>>, Args extends DefaultFunctionArgs, Visibility extends FunctionVisibility = "internal">(ctx: {
|
|
41
|
+
runWithRetries: <Action extends FunctionReference<"action", Visibility, Args, null | Promise<null> | void | Promise<void>> | FunctionReference_future<"action", Visibility, Args, null | Promise<null> | void | Promise<void>>, Args extends DefaultFunctionArgs, Visibility extends FunctionVisibility = "internal">(ctx: {
|
|
42
42
|
scheduler: Scheduler;
|
|
43
43
|
}, action: Action, actionArgs: Args, options?: {
|
|
44
44
|
waitBackoff?: number;
|
package/server/retries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retries.d.ts","sourceRoot":"","sources":["retries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAiBvB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;qBA+BC,MAAM,
|
|
1
|
+
{"version":3,"file":"retries.d.ts","sourceRoot":"","sources":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Reference_future,
|
|
8
9
|
FunctionVisibility,
|
|
9
10
|
Scheduler,
|
|
10
11
|
DefaultFunctionArgs,
|
|
@@ -91,12 +92,19 @@ export function makeActionRetrier(
|
|
|
91
92
|
* Defaults to 16.
|
|
92
93
|
*/
|
|
93
94
|
async function runWithRetries<
|
|
94
|
-
Action extends
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
Action extends
|
|
96
|
+
| FunctionReference<
|
|
97
|
+
"action",
|
|
98
|
+
Visibility,
|
|
99
|
+
Args,
|
|
100
|
+
null | Promise<null> | void | Promise<void>
|
|
101
|
+
>
|
|
102
|
+
| FunctionReference_future<
|
|
103
|
+
"action",
|
|
104
|
+
Visibility,
|
|
105
|
+
Args,
|
|
106
|
+
null | Promise<null> | void | Promise<void>
|
|
107
|
+
>,
|
|
100
108
|
Args extends DefaultFunctionArgs,
|
|
101
109
|
Visibility extends FunctionVisibility = "internal",
|
|
102
110
|
>(
|
package/server/sessions.d.ts
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
* See the associated [Stack post](https://stack.convex.dev/track-sessions-without-cookies)
|
|
53
53
|
* for more information.
|
|
54
54
|
*/
|
|
55
|
-
import type { FunctionArgs, FunctionReference, FunctionReturnType, GenericActionCtx, GenericDataModel } from "convex/server";
|
|
55
|
+
import type { FunctionArgs, FunctionReference, FunctionReference_future, FunctionReturnType, GenericActionCtx, GenericDataModel } from "convex/server";
|
|
56
56
|
import type { Validator } from "convex/values";
|
|
57
57
|
import type { BetterOmit, EmptyObject } from "../index.js";
|
|
58
58
|
export type SessionId = string & {
|
|
@@ -64,7 +64,9 @@ export declare const SessionIdArg: {
|
|
|
64
64
|
};
|
|
65
65
|
type SessionFunction<T extends "query" | "mutation" | "action", Args = any> = FunctionReference<T, "public" | "internal", {
|
|
66
66
|
sessionId: SessionId;
|
|
67
|
-
} & Args, any
|
|
67
|
+
} & Args, any> | FunctionReference_future<T, "public" | "internal", {
|
|
68
|
+
sessionId: SessionId;
|
|
69
|
+
} & Args>;
|
|
68
70
|
type SessionArgsArray<Fn extends SessionFunction<"query" | "mutation" | "action", any>> = keyof FunctionArgs<Fn> extends "sessionId" ? [args?: EmptyObject] : [args: BetterOmit<FunctionArgs<Fn>, "sessionId">];
|
|
69
71
|
export interface RunSessionFunctions {
|
|
70
72
|
/**
|
package/server/sessions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG3D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvD,eAAO,MAAM,UAAU,EAAiB,SAAS,CAAC,SAAS,CAAC,CAAC;AAC7D,eAAO,MAAM,YAAY;IAAK,SAAS;CAAc,CAAC;AAEtD,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAE,UA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Q,CAAC,GAClC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEzC;;;;;;;;;OASG;IACH,gBAAgB,CAAC,MAAM,SAAS,eAAe,CAAC,QAAQ,CAAC,EACvD,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAChC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;CACxC;AACD,wBAAgB,mBAAmB,CAAC,SAAS,SAAS,gBAAgB,EACpE,GAAG,EAAE,gBAAgB,CAAC,SAAS,CAAC,EAChC,SAAS,EAAE,SAAS,GACnB,mBAAmB,CAqBrB"}
|
package/server/sessions.ts
CHANGED
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
import type {
|
|
56
56
|
FunctionArgs,
|
|
57
57
|
FunctionReference,
|
|
58
|
+
FunctionReference_future,
|
|
58
59
|
FunctionReturnType,
|
|
59
60
|
GenericActionCtx,
|
|
60
61
|
GenericDataModel,
|
|
@@ -69,15 +70,18 @@ export type SessionId = string & { __SessionId: true };
|
|
|
69
70
|
export const vSessionId = v.string() as Validator<SessionId>;
|
|
70
71
|
export const SessionIdArg = { sessionId: vSessionId };
|
|
71
72
|
|
|
72
|
-
type SessionFunction<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
type SessionFunction<T extends "query" | "mutation" | "action", Args = any> =
|
|
74
|
+
| FunctionReference<
|
|
75
|
+
T,
|
|
76
|
+
"public" | "internal",
|
|
77
|
+
{ sessionId: SessionId } & Args,
|
|
78
|
+
any
|
|
79
|
+
>
|
|
80
|
+
| FunctionReference_future<
|
|
81
|
+
T,
|
|
82
|
+
"public" | "internal",
|
|
83
|
+
{ sessionId: SessionId } & Args
|
|
84
|
+
>;
|
|
81
85
|
|
|
82
86
|
type SessionArgsArray<
|
|
83
87
|
Fn extends SessionFunction<"query" | "mutation" | "action", any>,
|
package/testing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConvexClient } from "convex/browser";
|
|
2
|
-
import type { FunctionArgs, FunctionReference, FunctionReturnType, UserIdentity } from "convex/server";
|
|
2
|
+
import type { FunctionArgs, FunctionReference, FunctionReference_future, FunctionReturnType, UserIdentity } from "convex/server";
|
|
3
3
|
/**
|
|
4
4
|
* This is a helper for testing Convex functions against a locally running backend.
|
|
5
5
|
*
|
|
@@ -26,9 +26,9 @@ export declare class ConvexTestingHelper {
|
|
|
26
26
|
});
|
|
27
27
|
newIdentity(args: Partial<Omit<UserIdentity, "tokenIdentifier">>): Omit<UserIdentity, "tokenIdentifier">;
|
|
28
28
|
withIdentity(identity: Omit<UserIdentity, "tokenIdentifier">): Pick<ConvexClient, "mutation" | "action" | "query">;
|
|
29
|
-
mutation<Mutation extends FunctionReference<"mutation">>(mutation: Mutation, args: FunctionArgs<Mutation>): Promise<Awaited<FunctionReturnType<Mutation>>>;
|
|
30
|
-
query<Query extends FunctionReference<"query", "public">>(query: Query, args: FunctionArgs<Query>): Promise<Awaited<FunctionReturnType<Query>>>;
|
|
31
|
-
action<Action extends FunctionReference<"action">>(action: Action, args: FunctionArgs<Action>): Promise<Awaited<FunctionReturnType<Action>>>;
|
|
29
|
+
mutation<Mutation extends FunctionReference<"mutation"> | FunctionReference_future<"mutation">>(mutation: Mutation, args: FunctionArgs<Mutation>): Promise<Awaited<FunctionReturnType<Mutation>>>;
|
|
30
|
+
query<Query extends FunctionReference<"query", "public"> | FunctionReference_future<"query", "public">>(query: Query, args: FunctionArgs<Query>): Promise<Awaited<FunctionReturnType<Query>>>;
|
|
31
|
+
action<Action extends FunctionReference<"action"> | FunctionReference_future<"action">>(action: Action, args: FunctionArgs<Action>): Promise<Awaited<FunctionReturnType<Action>>>;
|
|
32
32
|
close(): Promise<void>;
|
|
33
33
|
}
|
|
34
34
|
//# sourceMappingURL=testing.d.ts.map
|
package/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,cAAc,CAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IAC5B,OAAO,CAAC,SAAS,CAAS;IAE1B,YAAY,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,EAQnE;IAED,WAAW,CACT,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,GACnD,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,CASvC;IAED,YAAY,CACV,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,GAC9C,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC,CAqBrD;IAEK,QAAQ,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACb,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,cAAc,CAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IAC5B,OAAO,CAAC,SAAS,CAAS;IAE1B,YAAY,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,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|
FunctionReference,
|
|
5
|
+
FunctionReference_future,
|
|
5
6
|
FunctionReturnType,
|
|
6
7
|
UserIdentity,
|
|
7
8
|
} from "convex/server";
|
|
@@ -75,21 +76,31 @@ export class ConvexTestingHelper {
|
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
async mutation<
|
|
79
|
+
async mutation<
|
|
80
|
+
Mutation extends
|
|
81
|
+
FunctionReference<"mutation"> | FunctionReference_future<"mutation">,
|
|
82
|
+
>(
|
|
79
83
|
mutation: Mutation,
|
|
80
84
|
args: FunctionArgs<Mutation>,
|
|
81
85
|
): Promise<Awaited<FunctionReturnType<Mutation>>> {
|
|
82
86
|
return this.client.mutation(mutation, args);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
async query<
|
|
89
|
+
async query<
|
|
90
|
+
Query extends
|
|
91
|
+
| FunctionReference<"query", "public">
|
|
92
|
+
| FunctionReference_future<"query", "public">,
|
|
93
|
+
>(
|
|
86
94
|
query: Query,
|
|
87
95
|
args: FunctionArgs<Query>,
|
|
88
96
|
): Promise<Awaited<FunctionReturnType<Query>>> {
|
|
89
97
|
return this.client.query(query, args);
|
|
90
98
|
}
|
|
91
99
|
|
|
92
|
-
async action<
|
|
100
|
+
async action<
|
|
101
|
+
Action extends
|
|
102
|
+
FunctionReference<"action"> | FunctionReference_future<"action">,
|
|
103
|
+
>(
|
|
93
104
|
action: Action,
|
|
94
105
|
args: FunctionArgs<Action>,
|
|
95
106
|
): Promise<Awaited<FunctionReturnType<Action>>> {
|