convex-helpers 0.1.114 → 0.1.116
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/bin.cjs +6 -4
- package/package.json +2 -2
- package/react/sessions.d.ts.map +1 -1
- package/react/sessions.js +23 -26
- package/react/sessions.ts +31 -39
- package/server/filter.d.ts.map +1 -1
- package/server/filter.js +1 -0
- package/server/filter.ts +1 -0
- package/server/hono.d.ts +8 -3
- package/server/hono.d.ts.map +1 -1
- package/server/hono.ts +12 -3
- package/tsconfig.json +3 -1
package/bin.cjs
CHANGED
|
@@ -4507,9 +4507,11 @@ ${requiredPropertiesStr}${propertiesStr}`;
|
|
|
4507
4507
|
(v) => v.type !== "null"
|
|
4508
4508
|
);
|
|
4509
4509
|
if (nonNullMembers.length === 1 && nullMember !== void 0) {
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4510
|
+
const innerSchema = generateSchemaFromValidator(nonNullMembers[0]);
|
|
4511
|
+
if (innerSchema === "{}") {
|
|
4512
|
+
return "{}";
|
|
4513
|
+
}
|
|
4514
|
+
return `${innerSchema}
|
|
4513
4515
|
nullable: true`;
|
|
4514
4516
|
}
|
|
4515
4517
|
const members = nonNullMembers.map(
|
|
@@ -4650,7 +4652,7 @@ components:
|
|
|
4650
4652
|
description: Token of the format "Bearer {token}" for normal authentication and "Convex {token}" for admin tokens.
|
|
4651
4653
|
schemas:
|
|
4652
4654
|
${reindent(
|
|
4653
|
-
functionSpec.functions.filter((f) => f.functionType !== "HttpAction").map((f) => generateEndpointSchemas(f)).join("\n"),
|
|
4655
|
+
functionSpec.functions.filter((f) => f.functionType !== "HttpAction").filter((f) => includeInternal || f.visibility.kind === "public").map((f) => generateEndpointSchemas(f)).join("\n"),
|
|
4654
4656
|
1
|
|
4655
4657
|
)}
|
|
4656
4658
|
FailedResponse:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "convex-helpers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.116",
|
|
4
4
|
"description": "A collection of useful code to complement the official convex package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"convex": "^1.32.0",
|
|
168
168
|
"hono": "^4.0.5",
|
|
169
169
|
"react": "^17.0.2 || ^18.0.0 || ^19.0.0",
|
|
170
|
-
"typescript": "^5.5",
|
|
170
|
+
"typescript": "^5.5 || ^6.0.0",
|
|
171
171
|
"zod": "^3.25.0 || ^4.0.0"
|
|
172
172
|
},
|
|
173
173
|
"peerDependenciesMeta": {
|
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,
|
|
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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;IACH,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAOxC;;;;OAIG;IACH,YAAY,IAAI,SAAS;IAIzB;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,SAAS,eAAe,CAAC,OAAO,CAAC,EACjD,KAAK,EAAE,KAAK,EACZ,GAAG,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAC/B,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAOrC;;;;;;OAMG;IACH,eAAe,CAAC,QAAQ,SAAS,eAAe,CAAC,UAAU,CAAC,EAC1D,QAAQ,EAAE,QAAQ,EAClB,GAAG,IAAI,EAAE,qBAAqB,CAC5B,QAAQ,EACR,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CACxC,GACA,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAWxC;;;;;;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;CAMvC"}
|
package/react/sessions.js
CHANGED
|
@@ -109,10 +109,10 @@ export const SessionProvider = ({ useStorage, storageKey, idGenerator, ssrFriend
|
|
|
109
109
|
*/
|
|
110
110
|
export function useSessionQuery(query, ...args) {
|
|
111
111
|
const [sessionId] = useSessionId();
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return useQuery(query,
|
|
112
|
+
const argsObject = args[0] === "skip" || !sessionId
|
|
113
|
+
? "skip"
|
|
114
|
+
: { ...args[0], sessionId };
|
|
115
|
+
return useQuery(query, argsObject);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Use this in place of {@link usePaginatedQuery} to run a query, passing a sessionId.
|
|
@@ -127,10 +127,10 @@ export function useSessionQuery(query, ...args) {
|
|
|
127
127
|
*/
|
|
128
128
|
export function useSessionPaginatedQuery(query, args, options) {
|
|
129
129
|
const [sessionId] = useSessionId();
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return usePaginatedQuery(query,
|
|
130
|
+
const argsObject = args === "skip" || !sessionId
|
|
131
|
+
? "skip"
|
|
132
|
+
: { ...args, sessionId };
|
|
133
|
+
return usePaginatedQuery(query, argsObject, options);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Use this in place of {@link useMutation} to run a mutation with a sessionId.
|
|
@@ -147,11 +147,11 @@ export function useSessionMutation(name) {
|
|
|
147
147
|
return useMemo(() => {
|
|
148
148
|
function createMutation(originalMutation) {
|
|
149
149
|
return async (...args) => {
|
|
150
|
-
const
|
|
151
|
-
...
|
|
150
|
+
const argsObject = {
|
|
151
|
+
...args[0],
|
|
152
152
|
sessionId: sessionId || (await sessionIdPromise),
|
|
153
153
|
};
|
|
154
|
-
return originalMutation(
|
|
154
|
+
return originalMutation(argsObject);
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
const mutation = createMutation(originalMutation);
|
|
@@ -174,11 +174,11 @@ export function useSessionAction(name) {
|
|
|
174
174
|
const [sessionId, _, sessionIdPromise] = useSessionId();
|
|
175
175
|
const originalAction = useAction(name);
|
|
176
176
|
return useCallback(async (...args) => {
|
|
177
|
-
const
|
|
178
|
-
...
|
|
177
|
+
const argsObject = {
|
|
178
|
+
...args[0],
|
|
179
179
|
sessionId: sessionId || (await sessionIdPromise),
|
|
180
180
|
};
|
|
181
|
-
return originalAction(
|
|
181
|
+
return originalAction(argsObject);
|
|
182
182
|
}, [sessionId, originalAction]);
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
@@ -332,11 +332,10 @@ export class ConvexReactSessionClient extends ConvexReactClient {
|
|
|
332
332
|
* @returns A promise of the query result
|
|
333
333
|
*/
|
|
334
334
|
sessionQuery(query, ...args) {
|
|
335
|
-
|
|
336
|
-
...
|
|
335
|
+
return this.query(query, {
|
|
336
|
+
...args[0],
|
|
337
337
|
sessionId: this.sessionId,
|
|
338
|
-
};
|
|
339
|
-
return this.query(query, newArgs);
|
|
338
|
+
});
|
|
340
339
|
}
|
|
341
340
|
/**
|
|
342
341
|
* Run a Convex mutation with the session ID injected.
|
|
@@ -346,11 +345,10 @@ export class ConvexReactSessionClient extends ConvexReactClient {
|
|
|
346
345
|
* @returns A promise of the mutation result
|
|
347
346
|
*/
|
|
348
347
|
sessionMutation(mutation, ...args) {
|
|
349
|
-
|
|
350
|
-
...
|
|
348
|
+
return this.mutation(mutation, {
|
|
349
|
+
...args[0],
|
|
351
350
|
sessionId: this.sessionId,
|
|
352
|
-
};
|
|
353
|
-
return this.mutation(mutation, newArgs, args[1]);
|
|
351
|
+
}, args[1]);
|
|
354
352
|
}
|
|
355
353
|
/**
|
|
356
354
|
* Run a Convex action with the session ID injected.
|
|
@@ -360,10 +358,9 @@ export class ConvexReactSessionClient extends ConvexReactClient {
|
|
|
360
358
|
* @returns A promise of the action result
|
|
361
359
|
*/
|
|
362
360
|
sessionAction(action, ...args) {
|
|
363
|
-
|
|
364
|
-
...
|
|
361
|
+
return this.action(action, {
|
|
362
|
+
...args[0],
|
|
365
363
|
sessionId: this.sessionId,
|
|
366
|
-
};
|
|
367
|
-
return this.action(action, newArgs);
|
|
364
|
+
});
|
|
368
365
|
}
|
|
369
366
|
}
|
package/react/sessions.ts
CHANGED
|
@@ -27,7 +27,6 @@ import type {
|
|
|
27
27
|
FunctionArgs,
|
|
28
28
|
FunctionReference,
|
|
29
29
|
FunctionReturnType,
|
|
30
|
-
OptionalRestArgs,
|
|
31
30
|
PaginationOptions,
|
|
32
31
|
PaginationResult,
|
|
33
32
|
} from "convex/server";
|
|
@@ -225,12 +224,11 @@ export function useSessionQuery<Query extends SessionFunction<"query">>(
|
|
|
225
224
|
...args: SessionQueryArgsArray<Query>
|
|
226
225
|
): FunctionReturnType<Query> | undefined {
|
|
227
226
|
const [sessionId] = useSessionId();
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return useQuery(query, ...([newArgs] as OptionalRestArgs<Query>));
|
|
227
|
+
const argsObject =
|
|
228
|
+
args[0] === "skip" || !sessionId
|
|
229
|
+
? ("skip" as const)
|
|
230
|
+
: ({ ...args[0], sessionId } as FunctionArgs<Query>);
|
|
231
|
+
return useQuery(query, argsObject);
|
|
234
232
|
}
|
|
235
233
|
|
|
236
234
|
/**
|
|
@@ -252,16 +250,12 @@ export function useSessionPaginatedQuery<
|
|
|
252
250
|
options: { initialNumItems: number },
|
|
253
251
|
): UsePaginatedQueryReturnType<Query> | undefined {
|
|
254
252
|
const [sessionId] = useSessionId();
|
|
255
|
-
const
|
|
256
|
-
|
|
253
|
+
const argsObject =
|
|
254
|
+
args === "skip" || !sessionId
|
|
255
|
+
? ("skip" as const)
|
|
256
|
+
: ({ ...args, sessionId } as PaginatedQueryArgs<Query>);
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return usePaginatedQuery(
|
|
261
|
-
query,
|
|
262
|
-
newArgs as PaginatedQueryArgs<Query> | "skip",
|
|
263
|
-
options,
|
|
264
|
-
);
|
|
258
|
+
return usePaginatedQuery(query, argsObject, options);
|
|
265
259
|
}
|
|
266
260
|
|
|
267
261
|
type SessionMutation<Mutation extends FunctionReference<"mutation">> = (
|
|
@@ -297,11 +291,11 @@ export function useSessionMutation<
|
|
|
297
291
|
originalMutation: ReactMutation<Mutation>,
|
|
298
292
|
): SessionMutation<Mutation> {
|
|
299
293
|
return async (...args) => {
|
|
300
|
-
const
|
|
301
|
-
...
|
|
294
|
+
const argsObject = {
|
|
295
|
+
...args[0],
|
|
302
296
|
sessionId: sessionId || (await sessionIdPromise),
|
|
303
|
-
}
|
|
304
|
-
return originalMutation(
|
|
297
|
+
} as FunctionArgs<Mutation>;
|
|
298
|
+
return originalMutation(argsObject);
|
|
305
299
|
};
|
|
306
300
|
}
|
|
307
301
|
const mutation = createMutation(
|
|
@@ -335,12 +329,12 @@ export function useSessionAction<Action extends SessionFunction<"action">>(
|
|
|
335
329
|
async (
|
|
336
330
|
...args: SessionArgsArray<Action>
|
|
337
331
|
): Promise<FunctionReturnType<Action>> => {
|
|
338
|
-
const
|
|
339
|
-
...
|
|
332
|
+
const argsObject = {
|
|
333
|
+
...args[0],
|
|
340
334
|
sessionId: sessionId || (await sessionIdPromise),
|
|
341
335
|
} as FunctionArgs<Action>;
|
|
342
336
|
|
|
343
|
-
return originalAction(
|
|
337
|
+
return originalAction(argsObject);
|
|
344
338
|
},
|
|
345
339
|
[sessionId, originalAction],
|
|
346
340
|
);
|
|
@@ -533,12 +527,10 @@ export class ConvexReactSessionClient extends ConvexReactClient {
|
|
|
533
527
|
query: Query,
|
|
534
528
|
...args: SessionArgsArray<Query>
|
|
535
529
|
): Promise<FunctionReturnType<Query>> {
|
|
536
|
-
|
|
537
|
-
...
|
|
530
|
+
return this.query(query, {
|
|
531
|
+
...args[0],
|
|
538
532
|
sessionId: this.sessionId,
|
|
539
|
-
} as FunctionArgs<Query
|
|
540
|
-
|
|
541
|
-
return this.query(query, newArgs);
|
|
533
|
+
} as FunctionArgs<Query>);
|
|
542
534
|
}
|
|
543
535
|
|
|
544
536
|
/**
|
|
@@ -555,12 +547,14 @@ export class ConvexReactSessionClient extends ConvexReactClient {
|
|
|
555
547
|
MutationOptions<FunctionArgs<Mutation>>
|
|
556
548
|
>
|
|
557
549
|
): Promise<FunctionReturnType<Mutation>> {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
550
|
+
return this.mutation(
|
|
551
|
+
mutation,
|
|
552
|
+
{
|
|
553
|
+
...args[0],
|
|
554
|
+
sessionId: this.sessionId,
|
|
555
|
+
} as FunctionArgs<Mutation>,
|
|
556
|
+
args[1],
|
|
557
|
+
);
|
|
564
558
|
}
|
|
565
559
|
|
|
566
560
|
/**
|
|
@@ -574,11 +568,9 @@ export class ConvexReactSessionClient extends ConvexReactClient {
|
|
|
574
568
|
action: Action,
|
|
575
569
|
...args: SessionArgsArray<Action>
|
|
576
570
|
): Promise<FunctionReturnType<Action>> {
|
|
577
|
-
|
|
578
|
-
...
|
|
571
|
+
return this.action(action, {
|
|
572
|
+
...args[0],
|
|
579
573
|
sessionId: this.sessionId,
|
|
580
|
-
} as FunctionArgs<Action
|
|
581
|
-
|
|
582
|
-
return this.action(action, newArgs);
|
|
574
|
+
} as FunctionArgs<Action>);
|
|
583
575
|
}
|
|
584
576
|
}
|
package/server/filter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["filter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAMhB,YAAY,EASb,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["filter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAMhB,YAAY,EASb,MAAM,eAAe,CAAC;AAsHvB,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,gBAAgB,IAAI,CAClD,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,KACnB,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEhC,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,YAAY,CAAC,gBAAgB,CAAC,EAC7D,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GACtC,CAAC,CAKH"}
|
package/server/filter.js
CHANGED
package/server/filter.ts
CHANGED
|
@@ -48,6 +48,7 @@ class QueryWithFilter<
|
|
|
48
48
|
this.p = p;
|
|
49
49
|
}
|
|
50
50
|
filter(predicate: (q: FilterBuilder<T>) => Expression<boolean>): this {
|
|
51
|
+
// eslint-disable-next-line @convex-dev/no-filter-in-query
|
|
51
52
|
return new QueryWithFilter(this.q.filter(predicate), this.p) as this;
|
|
52
53
|
}
|
|
53
54
|
order(order: "asc" | "desc"): QueryWithFilter<T> {
|
package/server/hono.d.ts
CHANGED
|
@@ -35,11 +35,16 @@ declare global {
|
|
|
35
35
|
/**
|
|
36
36
|
* A type representing a Hono app with `c.env` containing Convex's
|
|
37
37
|
* `HttpEndpointCtx` (e.g. `c.env.runQuery` is valid).
|
|
38
|
+
*
|
|
39
|
+
* Optionally accepts a `Variables` type parameter so consumers can use
|
|
40
|
+
* middleware-driven typed context state (`c.var` / `c.set` / `c.get`) without
|
|
41
|
+
* casting when passing the app to `HttpRouterWithHono`.
|
|
38
42
|
*/
|
|
39
|
-
export type HonoWithConvex<ActionCtx extends GenericActionCtx<any>> = Hono<{
|
|
43
|
+
export type HonoWithConvex<ActionCtx extends GenericActionCtx<any>, Variables extends Record<string, unknown> = Record<string, never>> = Hono<{
|
|
40
44
|
Bindings: {
|
|
41
45
|
[Name in keyof ActionCtx]: ActionCtx[Name];
|
|
42
46
|
};
|
|
47
|
+
Variables: Variables;
|
|
43
48
|
}>;
|
|
44
49
|
/**
|
|
45
50
|
* An implementation of the Convex `HttpRouter` that integrates with Hono by
|
|
@@ -65,11 +70,11 @@ export type HonoWithConvex<ActionCtx extends GenericActionCtx<any>> = Hono<{
|
|
|
65
70
|
* export default http;
|
|
66
71
|
* ```
|
|
67
72
|
*/
|
|
68
|
-
export declare class HttpRouterWithHono<ActionCtx extends GenericActionCtx<any>> extends HttpRouter {
|
|
73
|
+
export declare class HttpRouterWithHono<ActionCtx extends GenericActionCtx<any>, Variables extends Record<string, unknown> = Record<string, never>> extends HttpRouter {
|
|
69
74
|
private _app;
|
|
70
75
|
private _handler;
|
|
71
76
|
private _handlerInfoCache;
|
|
72
|
-
constructor(app: HonoWithConvex<ActionCtx>);
|
|
77
|
+
constructor(app: HonoWithConvex<ActionCtx, Variables>);
|
|
73
78
|
/**
|
|
74
79
|
* Get routes from the Hono app.
|
|
75
80
|
*/
|
package/server/hono.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["hono.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAEV,cAAc,EACd,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,UAAU,EAEX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB;;;;;GAKG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,KAAK,UAAU,GAAG,GAAG,CAAC;CACvB;AAED
|
|
1
|
+
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["hono.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAEV,cAAc,EACd,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,UAAU,EAEX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB;;;;;GAKG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,KAAK,UAAU,GAAG,GAAG,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,CACxB,SAAS,SAAS,gBAAgB,CAAC,GAAG,CAAC,EACvC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAC/D,IAAI,CAAC;IACP,QAAQ,EAAE;SACP,IAAI,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;KAC3C,CAAC;IACF,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,kBAAkB,CAC7B,SAAS,SAAS,gBAAgB,CAAC,GAAG,CAAC,EACvC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CACjE,SAAQ,UAAU;IAClB,OAAO,CAAC,IAAI,CAAuC;IACnD,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,iBAAiB,CAAqD;gBAElE,GAAG,EAAE,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC;IA+BrD;;OAEG;IACH,OAAO,CAAC,aAAa;IA0CrB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,eAAe;CAkCxB;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,GAAG,MAAM,GAC9B,cAAc,CAIhB"}
|
package/server/hono.ts
CHANGED
|
@@ -45,11 +45,19 @@ declare global {
|
|
|
45
45
|
/**
|
|
46
46
|
* A type representing a Hono app with `c.env` containing Convex's
|
|
47
47
|
* `HttpEndpointCtx` (e.g. `c.env.runQuery` is valid).
|
|
48
|
+
*
|
|
49
|
+
* Optionally accepts a `Variables` type parameter so consumers can use
|
|
50
|
+
* middleware-driven typed context state (`c.var` / `c.set` / `c.get`) without
|
|
51
|
+
* casting when passing the app to `HttpRouterWithHono`.
|
|
48
52
|
*/
|
|
49
|
-
export type HonoWithConvex<
|
|
53
|
+
export type HonoWithConvex<
|
|
54
|
+
ActionCtx extends GenericActionCtx<any>,
|
|
55
|
+
Variables extends Record<string, unknown> = Record<string, never>,
|
|
56
|
+
> = Hono<{
|
|
50
57
|
Bindings: {
|
|
51
58
|
[Name in keyof ActionCtx]: ActionCtx[Name];
|
|
52
59
|
};
|
|
60
|
+
Variables: Variables;
|
|
53
61
|
}>;
|
|
54
62
|
|
|
55
63
|
/**
|
|
@@ -78,12 +86,13 @@ export type HonoWithConvex<ActionCtx extends GenericActionCtx<any>> = Hono<{
|
|
|
78
86
|
*/
|
|
79
87
|
export class HttpRouterWithHono<
|
|
80
88
|
ActionCtx extends GenericActionCtx<any>,
|
|
89
|
+
Variables extends Record<string, unknown> = Record<string, never>,
|
|
81
90
|
> extends HttpRouter {
|
|
82
|
-
private _app: HonoWithConvex<ActionCtx>;
|
|
91
|
+
private _app: HonoWithConvex<ActionCtx, Variables>;
|
|
83
92
|
private _handler: PublicHttpAction;
|
|
84
93
|
private _handlerInfoCache: Map<any, { method: RoutableMethod; path: string }>;
|
|
85
94
|
|
|
86
|
-
constructor(app: HonoWithConvex<ActionCtx>) {
|
|
95
|
+
constructor(app: HonoWithConvex<ActionCtx, Variables>) {
|
|
87
96
|
super();
|
|
88
97
|
this._app = app;
|
|
89
98
|
// Single Convex httpEndpoint handler that just forwards the request to the
|
package/tsconfig.json
CHANGED
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
33
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
34
|
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
|
|
35
|
+
"types": [
|
|
36
|
+
"node"
|
|
37
|
+
] /* Specify type package names to be included without being referenced in a source file. */,
|
|
36
38
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
39
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
40
|
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|