convex-helpers 0.1.115 → 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 +5 -3
- package/package.json +1 -1
- package/server/hono.d.ts +8 -3
- package/server/hono.d.ts.map +1 -1
- package/server/hono.ts +12 -3
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(
|
package/package.json
CHANGED
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
|