better-convex 0.3.1 → 0.4.0
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/dist/auth/index.d.ts +80 -80
- package/dist/auth-nextjs/index.d.ts +1 -1
- package/dist/crpc/index.d.ts +2 -2
- package/dist/{http-types-CZo9Xx5R.d.ts → http-types-B3tM9Old.d.ts} +12 -6
- package/dist/react/index.d.ts +99 -14
- package/dist/react/index.js +81 -42
- package/dist/rsc/index.d.ts +82 -14
- package/dist/server/index.d.ts +21 -19
- package/dist/server/index.js +14 -2
- package/dist/{types-U9pc_wi1.d.ts → types-2L5nploW.d.ts} +1 -1
- package/package.json +1 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as better_auth_adapters0 from "better-auth/adapters";
|
|
2
2
|
import { DBAdapterDebugLogOption } from "better-auth/adapters";
|
|
3
3
|
import { BetterAuthDBSchema } from "better-auth/db";
|
|
4
|
-
import * as
|
|
4
|
+
import * as convex_server0 from "convex/server";
|
|
5
5
|
import { DocumentByName, FunctionReference, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, IdField, PaginationOptions, PaginationResult, SchemaDefinition, SystemFields, TableNamesInDataModel, internalMutationGeneric } from "convex/server";
|
|
6
6
|
import * as convex_values0 from "convex/values";
|
|
7
7
|
import { Infer } from "convex/values";
|
|
@@ -45,31 +45,31 @@ declare const createClient: <DataModel extends GenericDataModel, Schema$1 extend
|
|
|
45
45
|
}) => {
|
|
46
46
|
authFunctions: AuthFunctions;
|
|
47
47
|
triggers: Triggers<DataModel, Schema$1> | undefined;
|
|
48
|
-
adapter: (ctx: GenericCtx<DataModel>, createAuthOptions: (ctx: any) => BetterAuthOptions) =>
|
|
49
|
-
httpAdapter: (ctx: GenericCtx<DataModel>) =>
|
|
48
|
+
adapter: (ctx: GenericCtx<DataModel>, createAuthOptions: (ctx: any) => BetterAuthOptions) => better_auth_adapters0.AdapterFactory;
|
|
49
|
+
httpAdapter: (ctx: GenericCtx<DataModel>) => better_auth_adapters0.AdapterFactory;
|
|
50
50
|
triggersApi: () => {
|
|
51
|
-
beforeCreate:
|
|
52
|
-
data: any;
|
|
51
|
+
beforeCreate: convex_server0.RegisteredMutation<"internal", {
|
|
53
52
|
model: string;
|
|
53
|
+
data: any;
|
|
54
54
|
}, Promise<any>>;
|
|
55
|
-
beforeDelete:
|
|
55
|
+
beforeDelete: convex_server0.RegisteredMutation<"internal", {
|
|
56
56
|
model: string;
|
|
57
57
|
doc: any;
|
|
58
58
|
}, Promise<any>>;
|
|
59
|
-
beforeUpdate:
|
|
60
|
-
update: any;
|
|
59
|
+
beforeUpdate: convex_server0.RegisteredMutation<"internal", {
|
|
61
60
|
model: string;
|
|
61
|
+
update: any;
|
|
62
62
|
doc: any;
|
|
63
63
|
}, Promise<any>>;
|
|
64
|
-
onCreate:
|
|
64
|
+
onCreate: convex_server0.RegisteredMutation<"internal", {
|
|
65
65
|
model: string;
|
|
66
66
|
doc: any;
|
|
67
67
|
}, Promise<void>>;
|
|
68
|
-
onDelete:
|
|
68
|
+
onDelete: convex_server0.RegisteredMutation<"internal", {
|
|
69
69
|
model: string;
|
|
70
70
|
doc: any;
|
|
71
71
|
}, Promise<void>>;
|
|
72
|
-
onUpdate:
|
|
72
|
+
onUpdate: convex_server0.RegisteredMutation<"internal", {
|
|
73
73
|
model: string;
|
|
74
74
|
newDoc: any;
|
|
75
75
|
oldDoc: any;
|
|
@@ -149,7 +149,7 @@ declare const httpAdapter: <DataModel extends GenericDataModel, Schema$1 extends
|
|
|
149
149
|
authFunctions: AuthFunctions;
|
|
150
150
|
debugLogs?: DBAdapterDebugLogOption;
|
|
151
151
|
triggers?: Triggers<DataModel, Schema$1>;
|
|
152
|
-
}) =>
|
|
152
|
+
}) => better_auth_adapters0.AdapterFactory;
|
|
153
153
|
declare const dbAdapter: <DataModel extends GenericDataModel, Schema$1 extends SchemaDefinition<any, any>>(ctx: GenericCtx<DataModel>, createAuthOptions: (ctx: any) => BetterAuthOptions, {
|
|
154
154
|
authFunctions,
|
|
155
155
|
debugLogs,
|
|
@@ -160,34 +160,34 @@ declare const dbAdapter: <DataModel extends GenericDataModel, Schema$1 extends S
|
|
|
160
160
|
schema: Schema$1;
|
|
161
161
|
debugLogs?: DBAdapterDebugLogOption;
|
|
162
162
|
triggers?: Triggers<DataModel, Schema$1>;
|
|
163
|
-
}) =>
|
|
163
|
+
}) => better_auth_adapters0.AdapterFactory;
|
|
164
164
|
//#endregion
|
|
165
165
|
//#region src/auth/adapter-utils.d.ts
|
|
166
166
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
167
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
168
167
|
connector?: "AND" | "OR" | undefined;
|
|
169
|
-
|
|
168
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
170
169
|
field: string;
|
|
170
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
171
171
|
}, {
|
|
172
172
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
173
173
|
field: convex_values0.VString<string, "required">;
|
|
174
|
-
operator: convex_values0.VUnion<"
|
|
174
|
+
operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
|
|
175
175
|
value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
|
|
176
|
-
}, "required", "
|
|
176
|
+
}, "required", "connector" | "field" | "operator" | "value">;
|
|
177
177
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
178
178
|
limit?: number | undefined;
|
|
179
|
-
where?: {
|
|
180
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
181
|
-
connector?: "AND" | "OR" | undefined;
|
|
182
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
183
|
-
field: string;
|
|
184
|
-
}[] | undefined;
|
|
185
|
-
select?: string[] | undefined;
|
|
186
179
|
offset?: number | undefined;
|
|
180
|
+
select?: string[] | undefined;
|
|
187
181
|
sortBy?: {
|
|
188
182
|
field: string;
|
|
189
183
|
direction: "asc" | "desc";
|
|
190
184
|
} | undefined;
|
|
185
|
+
where?: {
|
|
186
|
+
connector?: "AND" | "OR" | undefined;
|
|
187
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
188
|
+
field: string;
|
|
189
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
190
|
+
}[] | undefined;
|
|
191
191
|
model: string;
|
|
192
192
|
}, {
|
|
193
193
|
limit: convex_values0.VFloat64<number | undefined, "optional">;
|
|
@@ -202,22 +202,22 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
202
202
|
field: convex_values0.VString<string, "required">;
|
|
203
203
|
}, "optional", "field" | "direction">;
|
|
204
204
|
where: convex_values0.VArray<{
|
|
205
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
206
205
|
connector?: "AND" | "OR" | undefined;
|
|
207
|
-
|
|
206
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
208
207
|
field: string;
|
|
208
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
209
209
|
}[] | undefined, convex_values0.VObject<{
|
|
210
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
211
210
|
connector?: "AND" | "OR" | undefined;
|
|
212
|
-
|
|
211
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
213
212
|
field: string;
|
|
213
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
214
214
|
}, {
|
|
215
215
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
216
216
|
field: convex_values0.VString<string, "required">;
|
|
217
|
-
operator: convex_values0.VUnion<"
|
|
217
|
+
operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
|
|
218
218
|
value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
|
|
219
|
-
}, "required", "
|
|
220
|
-
}, "required", "limit" | "
|
|
219
|
+
}, "required", "connector" | "field" | "operator" | "value">, "optional">;
|
|
220
|
+
}, "required", "limit" | "model" | "offset" | "select" | "sortBy" | "where" | "sortBy.field" | "sortBy.direction">;
|
|
221
221
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
222
222
|
declare const checkUniqueFields: <Schema$1 extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema$1, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
|
|
223
223
|
declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => Promise<D | null>;
|
|
@@ -245,7 +245,7 @@ declare const findOneHandler: (ctx: any, args: {
|
|
|
245
245
|
model: string;
|
|
246
246
|
select?: string[];
|
|
247
247
|
where?: any[];
|
|
248
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
248
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.GenericDocument | null>;
|
|
249
249
|
declare const findManyHandler: (ctx: any, args: {
|
|
250
250
|
model: string;
|
|
251
251
|
paginationOpts: any;
|
|
@@ -256,7 +256,7 @@ declare const findManyHandler: (ctx: any, args: {
|
|
|
256
256
|
field: string;
|
|
257
257
|
};
|
|
258
258
|
where?: any[];
|
|
259
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
259
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>;
|
|
260
260
|
declare const updateOneHandler: (ctx: any, args: {
|
|
261
261
|
input: {
|
|
262
262
|
model: string;
|
|
@@ -279,8 +279,8 @@ declare const updateManyHandler: (ctx: any, args: {
|
|
|
279
279
|
count: number;
|
|
280
280
|
ids: any[];
|
|
281
281
|
isDone: boolean;
|
|
282
|
-
continueCursor:
|
|
283
|
-
splitCursor?:
|
|
282
|
+
continueCursor: convex_server0.Cursor;
|
|
283
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
284
284
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
285
285
|
}>;
|
|
286
286
|
declare const deleteOneHandler: (ctx: any, args: {
|
|
@@ -291,7 +291,7 @@ declare const deleteOneHandler: (ctx: any, args: {
|
|
|
291
291
|
beforeDeleteHandle?: string;
|
|
292
292
|
skipBeforeHooks?: boolean;
|
|
293
293
|
onDeleteHandle?: string;
|
|
294
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
294
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.GenericDocument | undefined>;
|
|
295
295
|
declare const deleteManyHandler: (ctx: any, args: {
|
|
296
296
|
input: {
|
|
297
297
|
model: string;
|
|
@@ -305,8 +305,8 @@ declare const deleteManyHandler: (ctx: any, args: {
|
|
|
305
305
|
count: number;
|
|
306
306
|
ids: any[];
|
|
307
307
|
isDone: boolean;
|
|
308
|
-
continueCursor:
|
|
309
|
-
splitCursor?:
|
|
308
|
+
continueCursor: convex_server0.Cursor;
|
|
309
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
310
310
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
311
311
|
}>;
|
|
312
312
|
declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: Schema$1, createAuth: CreateAuth, options?: {
|
|
@@ -314,23 +314,23 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
314
314
|
/** Skip input validation for smaller generated types. Since these are internal functions, validation is optional. */
|
|
315
315
|
skipValidation?: boolean;
|
|
316
316
|
}) => {
|
|
317
|
-
create:
|
|
317
|
+
create: convex_server0.RegisteredMutation<"internal", {
|
|
318
318
|
select?: string[] | undefined;
|
|
319
319
|
beforeCreateHandle?: string | undefined;
|
|
320
320
|
onCreateHandle?: string | undefined;
|
|
321
321
|
input: {
|
|
322
|
-
data: any;
|
|
323
322
|
model: string;
|
|
323
|
+
data: any;
|
|
324
324
|
} | {
|
|
325
|
+
model: string;
|
|
325
326
|
data: {
|
|
326
327
|
[x: string]: unknown;
|
|
327
328
|
[x: number]: unknown;
|
|
328
329
|
[x: symbol]: unknown;
|
|
329
330
|
};
|
|
330
|
-
model: string;
|
|
331
331
|
};
|
|
332
332
|
}, Promise<any>>;
|
|
333
|
-
deleteMany:
|
|
333
|
+
deleteMany: convex_server0.RegisteredMutation<"internal", {
|
|
334
334
|
beforeDeleteHandle?: string | undefined;
|
|
335
335
|
onDeleteHandle?: string | undefined;
|
|
336
336
|
paginationOpts: {
|
|
@@ -346,10 +346,10 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
346
346
|
model: string;
|
|
347
347
|
} | {
|
|
348
348
|
where?: {
|
|
349
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
350
349
|
connector?: "AND" | "OR" | undefined;
|
|
351
|
-
|
|
350
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
352
351
|
field: string;
|
|
352
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
353
353
|
}[] | undefined;
|
|
354
354
|
model: string;
|
|
355
355
|
};
|
|
@@ -357,11 +357,11 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
357
357
|
count: number;
|
|
358
358
|
ids: any[];
|
|
359
359
|
isDone: boolean;
|
|
360
|
-
continueCursor:
|
|
361
|
-
splitCursor?:
|
|
360
|
+
continueCursor: convex_server0.Cursor;
|
|
361
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
362
362
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
363
363
|
}>>;
|
|
364
|
-
deleteOne:
|
|
364
|
+
deleteOne: convex_server0.RegisteredMutation<"internal", {
|
|
365
365
|
beforeDeleteHandle?: string | undefined;
|
|
366
366
|
onDeleteHandle?: string | undefined;
|
|
367
367
|
input: {
|
|
@@ -369,28 +369,29 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
369
369
|
model: string;
|
|
370
370
|
} | {
|
|
371
371
|
where?: {
|
|
372
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
373
372
|
connector?: "AND" | "OR" | undefined;
|
|
374
|
-
|
|
373
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
375
374
|
field: string;
|
|
375
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
376
376
|
}[] | undefined;
|
|
377
377
|
model: string;
|
|
378
378
|
};
|
|
379
|
-
}, Promise<
|
|
380
|
-
findMany:
|
|
381
|
-
limit?: number | undefined;
|
|
379
|
+
}, Promise<convex_server0.GenericDocument | undefined>>;
|
|
380
|
+
findMany: convex_server0.RegisteredQuery<"internal", {
|
|
382
381
|
join?: any;
|
|
383
|
-
|
|
384
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
385
|
-
connector?: "AND" | "OR" | undefined;
|
|
386
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
387
|
-
field: string;
|
|
388
|
-
}[] | undefined;
|
|
382
|
+
limit?: number | undefined;
|
|
389
383
|
offset?: number | undefined;
|
|
390
384
|
sortBy?: {
|
|
391
385
|
field: string;
|
|
392
386
|
direction: "asc" | "desc";
|
|
393
387
|
} | undefined;
|
|
388
|
+
where?: {
|
|
389
|
+
connector?: "AND" | "OR" | undefined;
|
|
390
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
391
|
+
field: string;
|
|
392
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
393
|
+
}[] | undefined;
|
|
394
|
+
model: string;
|
|
394
395
|
paginationOpts: {
|
|
395
396
|
id?: number;
|
|
396
397
|
endCursor?: string | null;
|
|
@@ -399,20 +400,19 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
399
400
|
numItems: number;
|
|
400
401
|
cursor: string | null;
|
|
401
402
|
};
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
findOne: convex_server24.RegisteredQuery<"internal", {
|
|
403
|
+
}, Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>>;
|
|
404
|
+
findOne: convex_server0.RegisteredQuery<"internal", {
|
|
405
405
|
join?: any;
|
|
406
|
+
select?: string[] | undefined;
|
|
406
407
|
where?: {
|
|
407
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
408
408
|
connector?: "AND" | "OR" | undefined;
|
|
409
|
-
|
|
409
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
410
410
|
field: string;
|
|
411
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
411
412
|
}[] | undefined;
|
|
412
|
-
select?: string[] | undefined;
|
|
413
413
|
model: string;
|
|
414
|
-
}, Promise<
|
|
415
|
-
updateMany:
|
|
414
|
+
}, Promise<convex_server0.GenericDocument | null>>;
|
|
415
|
+
updateMany: convex_server0.RegisteredMutation<"internal", {
|
|
416
416
|
beforeUpdateHandle?: string | undefined;
|
|
417
417
|
onUpdateHandle?: string | undefined;
|
|
418
418
|
paginationOpts: {
|
|
@@ -425,54 +425,54 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
425
425
|
};
|
|
426
426
|
input: {
|
|
427
427
|
where?: any[] | undefined;
|
|
428
|
-
update: any;
|
|
429
428
|
model: string;
|
|
429
|
+
update: any;
|
|
430
430
|
} | {
|
|
431
431
|
where?: {
|
|
432
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
433
432
|
connector?: "AND" | "OR" | undefined;
|
|
434
|
-
|
|
433
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
435
434
|
field: string;
|
|
435
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
436
436
|
}[] | undefined;
|
|
437
|
+
model: string;
|
|
437
438
|
update: {
|
|
438
439
|
[x: string]: unknown;
|
|
439
440
|
[x: number]: unknown;
|
|
440
441
|
[x: symbol]: unknown;
|
|
441
442
|
};
|
|
442
|
-
model: string;
|
|
443
443
|
};
|
|
444
444
|
}, Promise<{
|
|
445
445
|
count: number;
|
|
446
446
|
ids: any[];
|
|
447
447
|
isDone: boolean;
|
|
448
|
-
continueCursor:
|
|
449
|
-
splitCursor?:
|
|
448
|
+
continueCursor: convex_server0.Cursor;
|
|
449
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
450
450
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
451
451
|
}>>;
|
|
452
|
-
updateOne:
|
|
452
|
+
updateOne: convex_server0.RegisteredMutation<"internal", {
|
|
453
453
|
beforeUpdateHandle?: string | undefined;
|
|
454
454
|
onUpdateHandle?: string | undefined;
|
|
455
455
|
input: {
|
|
456
456
|
where?: any[] | undefined;
|
|
457
|
-
update: any;
|
|
458
457
|
model: string;
|
|
458
|
+
update: any;
|
|
459
459
|
} | {
|
|
460
460
|
where?: {
|
|
461
|
-
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
462
461
|
connector?: "AND" | "OR" | undefined;
|
|
463
|
-
|
|
462
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
464
463
|
field: string;
|
|
464
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
465
465
|
}[] | undefined;
|
|
466
|
+
model: string;
|
|
466
467
|
update: {
|
|
467
468
|
[x: string]: unknown;
|
|
468
469
|
[x: number]: unknown;
|
|
469
470
|
[x: symbol]: unknown;
|
|
470
471
|
};
|
|
471
|
-
model: string;
|
|
472
472
|
};
|
|
473
473
|
}, Promise<any>>;
|
|
474
|
-
getLatestJwks:
|
|
475
|
-
rotateKeys:
|
|
474
|
+
getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<any>>;
|
|
475
|
+
rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<any>>;
|
|
476
476
|
};
|
|
477
477
|
//#endregion
|
|
478
478
|
//#region src/auth/helpers.d.ts
|
package/dist/crpc/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as HttpProcedureCall, c as InferHttpInput, i as HttpErrorCode, l as InferHttpOutput, n as HttpClientError, o as HttpRouteInfo, r as HttpClientFromRouter, s as HttpRouteMap, t as HttpClient, u as isHttpClientError } from "../http-types-
|
|
2
|
-
import { C as PaginatedFnMeta, S as Meta, _ as ExtractPaginatedItem, a as ConvexInfiniteQueryMeta, b as InfiniteQueryInput, c as ConvexMutationKey, d as ConvexQueryMeta, f as ConvexQueryOptions, g as DecorateQuery, h as DecorateMutation, i as ConvexActionOptions, l as ConvexQueryHookOptions, m as DecorateInfiniteQuery, n as CRPCClient, o as ConvexInfiniteQueryOptions, p as DecorateAction, r as ConvexActionKey, s as ConvexInfiniteQueryOptionsWithRef, t as AuthType, u as ConvexQueryKey, v as FUNC_REF_SYMBOL, w as PaginationOpts, x as InfiniteQueryOptsParam, y as FnMeta } from "../types-
|
|
1
|
+
import { a as HttpProcedureCall, c as InferHttpInput, i as HttpErrorCode, l as InferHttpOutput, n as HttpClientError, o as HttpRouteInfo, r as HttpClientFromRouter, s as HttpRouteMap, t as HttpClient, u as isHttpClientError } from "../http-types-B3tM9Old.js";
|
|
2
|
+
import { C as PaginatedFnMeta, S as Meta, _ as ExtractPaginatedItem, a as ConvexInfiniteQueryMeta, b as InfiniteQueryInput, c as ConvexMutationKey, d as ConvexQueryMeta, f as ConvexQueryOptions, g as DecorateQuery, h as DecorateMutation, i as ConvexActionOptions, l as ConvexQueryHookOptions, m as DecorateInfiniteQuery, n as CRPCClient, o as ConvexInfiniteQueryOptions, p as DecorateAction, r as ConvexActionKey, s as ConvexInfiniteQueryOptionsWithRef, t as AuthType, u as ConvexQueryKey, v as FUNC_REF_SYMBOL, w as PaginationOpts, x as InfiniteQueryOptsParam, y as FnMeta } from "../types-2L5nploW.js";
|
|
3
3
|
import { FunctionArgs, FunctionReference } from "convex/server";
|
|
4
4
|
|
|
5
5
|
//#region src/crpc/error.d.ts
|
|
@@ -91,13 +91,14 @@ type InferHttpInput$1<T> = T extends UnsetMarker ? undefined : T extends z.ZodTy
|
|
|
91
91
|
* Internal definition for HttpProcedureBuilder
|
|
92
92
|
* Stores schema types directly (like QueryProcedureBuilder)
|
|
93
93
|
*/
|
|
94
|
-
interface HttpProcedureBuilderDef<TCtx, TInput$1 extends UnsetMarker | z.ZodTypeAny, TOutput$1 extends UnsetMarker | z.ZodTypeAny, TParams$1 extends UnsetMarker | z.ZodTypeAny, TQuery$1 extends UnsetMarker | z.ZodTypeAny, TMeta extends ProcedureMeta, TMethod extends HttpMethod = HttpMethod> {
|
|
94
|
+
interface HttpProcedureBuilderDef<TCtx, TInput$1 extends UnsetMarker | z.ZodTypeAny, TOutput$1 extends UnsetMarker | z.ZodTypeAny, TParams$1 extends UnsetMarker | z.ZodTypeAny, TQuery$1 extends UnsetMarker | z.ZodTypeAny, TMeta extends ProcedureMeta, TMethod extends HttpMethod = HttpMethod, TForm extends UnsetMarker | z.ZodTypeAny = UnsetMarker> {
|
|
95
95
|
middlewares: AnyMiddleware[];
|
|
96
96
|
meta: TMeta;
|
|
97
97
|
inputSchema?: z.ZodTypeAny;
|
|
98
98
|
outputSchema?: z.ZodTypeAny;
|
|
99
99
|
paramsSchema?: z.ZodTypeAny;
|
|
100
100
|
querySchema?: z.ZodTypeAny;
|
|
101
|
+
formSchema?: z.ZodTypeAny;
|
|
101
102
|
route?: HttpRouteDefinition<TMethod>;
|
|
102
103
|
functionConfig: {
|
|
103
104
|
base: HttpActionConstructor;
|
|
@@ -109,13 +110,14 @@ interface HttpProcedureBuilderDef<TCtx, TInput$1 extends UnsetMarker | z.ZodType
|
|
|
109
110
|
output: TOutput$1;
|
|
110
111
|
params: TParams$1;
|
|
111
112
|
query: TQuery$1;
|
|
113
|
+
form: TForm;
|
|
112
114
|
};
|
|
113
115
|
}
|
|
114
116
|
type HttpActionConstructor = (handler: (ctx: GenericActionCtx<GenericDataModel>, request: Request) => Promise<Response>) => HttpActionHandler;
|
|
115
117
|
interface HttpActionHandler {
|
|
116
118
|
isHttp: true;
|
|
117
119
|
}
|
|
118
|
-
interface HttpProcedure<TInput$1 extends UnsetMarker | z.ZodTypeAny = any, TOutput$1 extends UnsetMarker | z.ZodTypeAny = any, TParams$1 extends UnsetMarker | z.ZodTypeAny = any, TQuery$1 extends UnsetMarker | z.ZodTypeAny = any, TMethod extends HttpMethod = HttpMethod> extends HttpActionHandler {
|
|
120
|
+
interface HttpProcedure<TInput$1 extends UnsetMarker | z.ZodTypeAny = any, TOutput$1 extends UnsetMarker | z.ZodTypeAny = any, TParams$1 extends UnsetMarker | z.ZodTypeAny = any, TQuery$1 extends UnsetMarker | z.ZodTypeAny = any, TMethod extends HttpMethod = HttpMethod, TForm extends UnsetMarker | z.ZodTypeAny = any> extends HttpActionHandler {
|
|
119
121
|
_crpcHttpRoute: HttpRouteDefinition<TMethod>;
|
|
120
122
|
/** @internal Expose def for client-side type inference */
|
|
121
123
|
_def: {
|
|
@@ -123,6 +125,7 @@ interface HttpProcedure<TInput$1 extends UnsetMarker | z.ZodTypeAny = any, TOutp
|
|
|
123
125
|
outputSchema?: TOutput$1;
|
|
124
126
|
paramsSchema?: TParams$1;
|
|
125
127
|
querySchema?: TQuery$1;
|
|
128
|
+
formSchema?: TForm;
|
|
126
129
|
};
|
|
127
130
|
}
|
|
128
131
|
/**
|
|
@@ -130,18 +133,21 @@ interface HttpProcedure<TInput$1 extends UnsetMarker | z.ZodTypeAny = any, TOutp
|
|
|
130
133
|
* - ctx: context properties (userId, db, runQuery, etc.)
|
|
131
134
|
* - input: parsed JSON body
|
|
132
135
|
* - params: parsed path params
|
|
133
|
-
* -
|
|
136
|
+
* - searchParams: parsed query params
|
|
137
|
+
* - form: parsed form data
|
|
134
138
|
* - c: Hono Context for Response helpers (c.json, c.text, c.redirect, c.header, c.req)
|
|
135
139
|
*/
|
|
136
|
-
type HttpHandlerOpts<TCtx, TInput$1 extends UnsetMarker | z.ZodTypeAny, TParams$1 extends UnsetMarker | z.ZodTypeAny,
|
|
140
|
+
type HttpHandlerOpts<TCtx, TInput$1 extends UnsetMarker | z.ZodTypeAny, TParams$1 extends UnsetMarker | z.ZodTypeAny, TSearchParams extends UnsetMarker | z.ZodTypeAny, TForm extends UnsetMarker | z.ZodTypeAny> = {
|
|
137
141
|
ctx: TCtx;
|
|
138
142
|
c: Context;
|
|
139
143
|
} & (TInput$1 extends UnsetMarker ? object : {
|
|
140
144
|
input: z.output<TInput$1>;
|
|
141
145
|
}) & (TParams$1 extends UnsetMarker ? object : {
|
|
142
146
|
params: z.output<TParams$1>;
|
|
143
|
-
}) & (
|
|
144
|
-
|
|
147
|
+
}) & (TSearchParams extends UnsetMarker ? object : {
|
|
148
|
+
searchParams: z.output<TSearchParams>;
|
|
149
|
+
}) & (TForm extends UnsetMarker ? object : {
|
|
150
|
+
form: z.output<TForm>;
|
|
145
151
|
});
|
|
146
152
|
/**
|
|
147
153
|
* Hono handler with cRPC route metadata attached
|
package/dist/react/index.d.ts
CHANGED
|
@@ -386,7 +386,7 @@ interface HttpRouteDefinition<TMethod extends HttpMethod = HttpMethod> {
|
|
|
386
386
|
interface HttpActionHandler {
|
|
387
387
|
isHttp: true;
|
|
388
388
|
}
|
|
389
|
-
interface HttpProcedure<TInput$1 extends UnsetMarker | z.ZodTypeAny = any, TOutput$1 extends UnsetMarker | z.ZodTypeAny = any, TParams$1 extends UnsetMarker | z.ZodTypeAny = any, TQuery$1 extends UnsetMarker | z.ZodTypeAny = any, TMethod extends HttpMethod = HttpMethod> extends HttpActionHandler {
|
|
389
|
+
interface HttpProcedure<TInput$1 extends UnsetMarker | z.ZodTypeAny = any, TOutput$1 extends UnsetMarker | z.ZodTypeAny = any, TParams$1 extends UnsetMarker | z.ZodTypeAny = any, TQuery$1 extends UnsetMarker | z.ZodTypeAny = any, TMethod extends HttpMethod = HttpMethod, TForm$1 extends UnsetMarker | z.ZodTypeAny = any> extends HttpActionHandler {
|
|
390
390
|
_crpcHttpRoute: HttpRouteDefinition<TMethod>;
|
|
391
391
|
/** @internal Expose def for client-side type inference */
|
|
392
392
|
_def: {
|
|
@@ -394,6 +394,7 @@ interface HttpProcedure<TInput$1 extends UnsetMarker | z.ZodTypeAny = any, TOutp
|
|
|
394
394
|
outputSchema?: TOutput$1;
|
|
395
395
|
paramsSchema?: TParams$1;
|
|
396
396
|
querySchema?: TQuery$1;
|
|
397
|
+
formSchema?: TForm$1;
|
|
397
398
|
};
|
|
398
399
|
}
|
|
399
400
|
//#endregion
|
|
@@ -626,10 +627,81 @@ type HttpRouteInfo = {
|
|
|
626
627
|
method: string;
|
|
627
628
|
};
|
|
628
629
|
type HttpRouteMap = Record<string, HttpRouteInfo>;
|
|
630
|
+
/** Form value types (matches Hono's FormValue) */
|
|
631
|
+
type HttpFormValue = string | Blob;
|
|
632
|
+
/**
|
|
633
|
+
* Hybrid input args: JSON body fields at root, explicit params/searchParams/form.
|
|
634
|
+
* - JSON body: spread at root level (tRPC-style)
|
|
635
|
+
* - Path params: { params: { id: '123' } }
|
|
636
|
+
* - Query params: { searchParams: { limit: '10' } }
|
|
637
|
+
* - Form data: { form: { file: blob } } - typed via .form() builder
|
|
638
|
+
* - Client options: { headers, fetch, init } - for per-call customization
|
|
639
|
+
*/
|
|
640
|
+
type HttpInputArgs = {
|
|
641
|
+
/** Path parameters (e.g., :id in /users/:id) */
|
|
642
|
+
params?: Record<string, string>;
|
|
643
|
+
/** Query string parameters */
|
|
644
|
+
searchParams?: Record<string, string | string[]>;
|
|
645
|
+
/** Form data body (Content-Type: multipart/form-data) - typed via .form() builder */
|
|
646
|
+
form?: Record<string, HttpFormValue | HttpFormValue[]>;
|
|
647
|
+
/** Custom fetch function (per-call override) */
|
|
648
|
+
fetch?: typeof fetch;
|
|
649
|
+
/** Standard RequestInit (per-call override) */
|
|
650
|
+
init?: RequestInit;
|
|
651
|
+
/** Additional headers (per-call override) */
|
|
652
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
653
|
+
/** Any other properties are JSON body fields */
|
|
654
|
+
[key: string]: unknown;
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* Client request options (matches Hono's ClientRequestOptions).
|
|
658
|
+
* Standard RequestInit in `init` takes highest priority and can override
|
|
659
|
+
* things that are set automatically like body, method, headers.
|
|
660
|
+
*/
|
|
661
|
+
type HttpClientOptions = {
|
|
662
|
+
/** Custom fetch function */
|
|
663
|
+
fetch?: typeof fetch;
|
|
664
|
+
/**
|
|
665
|
+
* Standard RequestInit - takes highest priority.
|
|
666
|
+
* Can override body, method, headers if needed.
|
|
667
|
+
*/
|
|
668
|
+
init?: RequestInit;
|
|
669
|
+
/** Additional headers (or async function returning headers) */
|
|
670
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
671
|
+
};
|
|
629
672
|
/** Infer schema type or return empty object if UnsetMarker */
|
|
630
673
|
type InferSchemaOrEmpty<T> = T extends UnsetMarker ? object : T extends z.ZodTypeAny ? z.infer<T> : object;
|
|
631
|
-
/** Infer merged input from HttpProcedure */
|
|
674
|
+
/** Infer merged input from HttpProcedure (flat - used internally) */
|
|
632
675
|
type InferHttpInput<T> = T extends HttpProcedure<infer TInput, infer _TOutput, infer TParams, infer TQuery> ? Simplify<InferSchemaOrEmpty<TParams> & InferSchemaOrEmpty<TQuery> & InferSchemaOrEmpty<TInput>> : object;
|
|
676
|
+
/**
|
|
677
|
+
* Extract string keys from a Zod object schema.
|
|
678
|
+
* Used for param/query which are always strings in URLs.
|
|
679
|
+
*/
|
|
680
|
+
type ZodObjectKeys<T> = T extends z.ZodObject<infer Shape> ? { [K in keyof Shape]: string } : Record<string, string>;
|
|
681
|
+
/**
|
|
682
|
+
* Extract string or string[] keys from a Zod object schema.
|
|
683
|
+
* Query params can have array values.
|
|
684
|
+
*/
|
|
685
|
+
type ZodQueryKeys<T> = T extends z.ZodObject<infer Shape> ? { [K in keyof Shape]?: string | string[] } : Record<string, string | string[]>;
|
|
686
|
+
/**
|
|
687
|
+
* Infer client-side args from HttpProcedure with proper nesting.
|
|
688
|
+
* - params: only present if TParams is defined, always strings (URL path params)
|
|
689
|
+
* - searchParams: only present if TQuery is defined, always strings (URL query params)
|
|
690
|
+
* - form: only present if TForm is defined, typed from schema
|
|
691
|
+
* - JSON body fields spread at root level (typed from schema)
|
|
692
|
+
* - Client options (fetch, init, headers) always optional for per-call overrides
|
|
693
|
+
*/
|
|
694
|
+
type InferHttpClientArgs<T> = T extends HttpProcedure<infer TInput, infer _TOutput, infer TParams, infer TQuery, infer _TMethod, infer TForm> ? Simplify<(TParams extends UnsetMarker ? object : {
|
|
695
|
+
params: ZodObjectKeys<TParams>;
|
|
696
|
+
}) & (TQuery extends UnsetMarker ? object : {
|
|
697
|
+
searchParams: ZodQueryKeys<TQuery>;
|
|
698
|
+
}) & (TForm extends UnsetMarker ? object : TForm extends z.ZodTypeAny ? {
|
|
699
|
+
form: z.infer<TForm>;
|
|
700
|
+
} : object) & (TInput extends UnsetMarker ? object : TInput extends z.ZodTypeAny ? z.infer<TInput> : object) & {
|
|
701
|
+
fetch?: typeof fetch;
|
|
702
|
+
init?: RequestInit;
|
|
703
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
704
|
+
}> : HttpInputArgs;
|
|
633
705
|
/** Infer output type from HttpProcedure */
|
|
634
706
|
type InferHttpOutput<T> = T extends HttpProcedure<infer _TInput, infer TOutput, infer _TParams, infer _TQuery> ? TOutput extends UnsetMarker ? unknown : TOutput extends z.ZodTypeAny ? z.infer<TOutput> : unknown : unknown;
|
|
635
707
|
/** Query key with args (3-element) or prefix key without args (2-element) for invalidation */
|
|
@@ -637,25 +709,38 @@ type HttpQueryKey = readonly ['httpQuery', string, unknown] | readonly ['httpQue
|
|
|
637
709
|
type HttpMutationKey = readonly ['httpMutation', string];
|
|
638
710
|
type ReservedQueryOptions$1 = 'queryKey' | 'queryFn';
|
|
639
711
|
type ReservedMutationOptions$1 = 'mutationFn';
|
|
640
|
-
/** Variables type for mutations - void when no args required */
|
|
641
|
-
type HttpMutationVariables<T extends HttpProcedure> = keyof InferHttpInput<T> extends never ? void : object extends InferHttpInput<T> ? InferHttpInput<T> | undefined : InferHttpInput<T>;
|
|
642
712
|
/** Query options for GET HTTP endpoints - compatible with both useQuery and useSuspenseQuery */
|
|
643
713
|
type HttpQueryOptsReturn<T extends HttpProcedure> = Omit<UseQueryOptions<InferHttpOutput<T>, Error, InferHttpOutput<T>, HttpQueryKey>, 'queryFn'> & {
|
|
644
714
|
queryFn: () => Promise<InferHttpOutput<T>>;
|
|
645
715
|
};
|
|
646
|
-
/** Mutation options for POST/PUT/PATCH/DELETE HTTP endpoints */
|
|
647
|
-
type HttpMutationOptsReturn<T extends HttpProcedure> = UseMutationOptions<InferHttpOutput<T>, DefaultError,
|
|
648
|
-
/**
|
|
716
|
+
/** Mutation options for POST/PUT/PATCH/DELETE HTTP endpoints - typed variables */
|
|
717
|
+
type HttpMutationOptsReturn<T extends HttpProcedure> = UseMutationOptions<InferHttpOutput<T>, DefaultError, InferHttpClientArgs<T>>;
|
|
718
|
+
/** Query options (TanStack Query only - client opts go in args) */
|
|
719
|
+
type HttpQueryOptions<T extends HttpProcedure> = DistributiveOmit<HttpQueryOptsReturn<T>, ReservedQueryOptions$1>;
|
|
720
|
+
/** Mutation options (TanStack Query only - client opts go in mutate args) */
|
|
721
|
+
type HttpMutationOptions<T extends HttpProcedure> = DistributiveOmit<HttpMutationOptsReturn<T>, ReservedMutationOptions$1>;
|
|
722
|
+
/**
|
|
723
|
+
* Decorated GET procedure with queryOptions and mutationOptions.
|
|
724
|
+
* - queryOptions: For cached data fetching (useQuery/useSuspenseQuery)
|
|
725
|
+
* - mutationOptions: For one-time actions like exports (useMutation)
|
|
726
|
+
*/
|
|
649
727
|
type DecorateHttpQuery<T extends HttpProcedure> = {
|
|
650
|
-
queryOptions: keyof InferHttpInput<T> extends never ? (args?:
|
|
728
|
+
queryOptions: keyof InferHttpInput<T> extends never ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : object extends InferHttpInput<T> ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : (args: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T>;
|
|
651
729
|
/** Get query key for QueryClient methods (with args = exact match, without = prefix) */
|
|
652
|
-
queryKey: (args?:
|
|
730
|
+
queryKey: (args?: InferHttpClientArgs<T>) => HttpQueryKey;
|
|
653
731
|
/** Get query filter for QueryClient methods (e.g., invalidateQueries) */
|
|
654
|
-
queryFilter: (args?:
|
|
732
|
+
queryFilter: (args?: InferHttpClientArgs<T>, filters?: DistributiveOmit<QueryFilters, 'queryKey'>) => QueryFilters;
|
|
733
|
+
/** Mutation options for GET endpoints (exports, downloads - no caching) */
|
|
734
|
+
mutationOptions: (opts?: HttpMutationOptions<T>) => HttpMutationOptsReturn<T>;
|
|
735
|
+
/** Get mutation key for QueryClient methods */
|
|
736
|
+
mutationKey: () => HttpMutationKey;
|
|
655
737
|
};
|
|
656
|
-
/**
|
|
738
|
+
/**
|
|
739
|
+
* Decorated POST/PUT/PATCH/DELETE procedure with mutationOptions.
|
|
740
|
+
* The mutationFn receives typed args inferred from server schemas.
|
|
741
|
+
*/
|
|
657
742
|
type DecorateHttpMutation<T extends HttpProcedure> = {
|
|
658
|
-
mutationOptions: (opts?:
|
|
743
|
+
mutationOptions: (opts?: HttpMutationOptions<T>) => HttpMutationOptsReturn<T>;
|
|
659
744
|
/** Get mutation key for QueryClient methods */
|
|
660
745
|
mutationKey: () => HttpMutationKey;
|
|
661
746
|
};
|
|
@@ -664,7 +749,7 @@ type DecorateHttpMutation<T extends HttpProcedure> = {
|
|
|
664
749
|
* Maps each procedure to queryOptions (GET) or mutationOptions (POST/etc).
|
|
665
750
|
* Uses infer to extract the method type literal for proper GET/non-GET distinction.
|
|
666
751
|
*/
|
|
667
|
-
type HttpCRPCClient<T extends HttpRouterRecord> = { [K in keyof T]: T[K] extends HttpProcedure<infer _TInput, infer _TOutput, infer _TParams, infer _TQuery, infer TMethod> ? TMethod extends 'GET' ? DecorateHttpQuery<T[K]> : DecorateHttpMutation<T[K]> : T[K] extends CRPCHttpRouter<infer R> ? HttpCRPCClient<R> : T[K] extends HttpRouterRecord ? HttpCRPCClient<T[K]> : never };
|
|
752
|
+
type HttpCRPCClient<T extends HttpRouterRecord> = { [K in keyof T]: T[K] extends HttpProcedure<infer _TInput, infer _TOutput, infer _TParams, infer _TQuery, infer TMethod, infer _TForm> ? TMethod extends 'GET' ? DecorateHttpQuery<T[K]> : DecorateHttpMutation<T[K]> : T[K] extends CRPCHttpRouter<infer R> ? HttpCRPCClient<R> : T[K] extends HttpRouterRecord ? HttpCRPCClient<T[K]> : never };
|
|
668
753
|
/**
|
|
669
754
|
* HTTP Client type from a CRPCHttpRouter.
|
|
670
755
|
* Use this when your type is the router object (with _def).
|
|
@@ -1057,4 +1142,4 @@ declare function useUploadMutationOptions<TGenerateUrlMutation extends FunctionR
|
|
|
1057
1142
|
file: File;
|
|
1058
1143
|
} & FunctionArgs<TGenerateUrlMutation>>;
|
|
1059
1144
|
//#endregion
|
|
1060
|
-
export { AuthProvider, AuthStore, AuthStoreState, Authenticated, CRPCHttpOptions, ConvexProvider, ConvexQueryClient, ConvexQueryClientOptions, ConvexQueryClientSingletonOptions, ConvexReactClient, CreateCRPCContextOptions, FetchAccessTokenContext, FetchAccessTokenFn, HttpCRPCClient, HttpCRPCClientFromRouter, HttpMutationKey, HttpProxyOptions, HttpQueryKey, HttpRouteInfo, HttpRouteMap, MaybeAuthenticated, MaybeUnauthenticated, PaginationState, PaginationStatus, Unauthenticated, UseInfiniteQueryResult, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvexActionOptions, useConvexActionQueryOptions, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
|
|
1145
|
+
export { AuthProvider, AuthStore, AuthStoreState, Authenticated, CRPCHttpOptions, ConvexProvider, ConvexQueryClient, ConvexQueryClientOptions, ConvexQueryClientSingletonOptions, ConvexReactClient, CreateCRPCContextOptions, FetchAccessTokenContext, FetchAccessTokenFn, HttpCRPCClient, HttpCRPCClientFromRouter, HttpClientOptions, HttpFormValue, HttpInputArgs, HttpMutationKey, HttpProxyOptions, HttpQueryKey, HttpRouteInfo, HttpRouteMap, MaybeAuthenticated, MaybeUnauthenticated, PaginationState, PaginationStatus, Unauthenticated, UseInfiniteQueryResult, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvexActionOptions, useConvexActionQueryOptions, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
|
package/dist/react/index.js
CHANGED
|
@@ -26,46 +26,86 @@ var HttpClientError = class extends Error {
|
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/react/http-proxy.ts
|
|
29
|
+
/** Reserved keys that are not part of JSON body */
|
|
30
|
+
const RESERVED_KEYS = new Set([
|
|
31
|
+
"params",
|
|
32
|
+
"searchParams",
|
|
33
|
+
"form",
|
|
34
|
+
"fetch",
|
|
35
|
+
"init",
|
|
36
|
+
"headers"
|
|
37
|
+
]);
|
|
29
38
|
/**
|
|
30
|
-
*
|
|
31
|
-
* e.g., '/users/:id
|
|
39
|
+
* Replace URL path parameters with actual values.
|
|
40
|
+
* e.g., '/users/:id' with { id: '123' } -> '/users/123'
|
|
32
41
|
*/
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
function replaceUrlParam(url, params) {
|
|
43
|
+
return url.replace(/:(\w+)/g, (_, key) => {
|
|
44
|
+
const value = params[key];
|
|
45
|
+
return value !== void 0 ? encodeURIComponent(value) : `:${key}`;
|
|
46
|
+
});
|
|
36
47
|
}
|
|
37
48
|
/**
|
|
38
|
-
*
|
|
49
|
+
* Build URLSearchParams from query object.
|
|
50
|
+
* Handles array values as multiple params with same key (like Hono).
|
|
51
|
+
*/
|
|
52
|
+
function buildSearchParams(query) {
|
|
53
|
+
const params = new URLSearchParams();
|
|
54
|
+
for (const [key, value] of Object.entries(query)) if (Array.isArray(value)) for (const v of value) params.append(key, v);
|
|
55
|
+
else if (value !== void 0 && value !== null) params.append(key, value);
|
|
56
|
+
return params;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Hono-style HTTP request executor.
|
|
60
|
+
* Processes args in the same way as Hono's ClientRequestImpl.fetch().
|
|
39
61
|
*/
|
|
40
62
|
async function executeHttpRequest(opts) {
|
|
41
63
|
const { method, path } = opts.route;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (method === "GET") {
|
|
51
|
-
const queryInput = input ? Object.fromEntries(Object.entries(input).filter(([k]) => !pathParamNames.includes(k))) : {};
|
|
52
|
-
if (Object.keys(queryInput).length > 0) {
|
|
53
|
-
const params = new URLSearchParams();
|
|
54
|
-
for (const [key, value] of Object.entries(queryInput)) if (value !== void 0 && value !== null) params.append(key, String(value));
|
|
55
|
-
const queryString = params.toString();
|
|
56
|
-
if (queryString) url += `?${queryString}`;
|
|
57
|
-
}
|
|
64
|
+
const args = opts.args ?? {};
|
|
65
|
+
let rBody;
|
|
66
|
+
let cType;
|
|
67
|
+
if (args.form) {
|
|
68
|
+
const form = new FormData();
|
|
69
|
+
for (const [k, v] of Object.entries(args.form)) if (Array.isArray(v)) for (const v2 of v) form.append(k, v2);
|
|
70
|
+
else form.append(k, v);
|
|
71
|
+
rBody = form;
|
|
58
72
|
} else {
|
|
59
|
-
const
|
|
60
|
-
|
|
73
|
+
const jsonBody = {};
|
|
74
|
+
for (const [key, value] of Object.entries(args)) if (!RESERVED_KEYS.has(key) && value !== void 0) jsonBody[key] = value;
|
|
75
|
+
if (Object.keys(jsonBody).length > 0) {
|
|
76
|
+
rBody = JSON.stringify(jsonBody);
|
|
77
|
+
cType = "application/json";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const argsClientOpts = {};
|
|
81
|
+
if (args.fetch) argsClientOpts.fetch = args.fetch;
|
|
82
|
+
if (args.init) argsClientOpts.init = args.init;
|
|
83
|
+
if (args.headers) argsClientOpts.headers = args.headers;
|
|
84
|
+
const mergedClientOpts = {
|
|
85
|
+
...opts.clientOpts,
|
|
86
|
+
...argsClientOpts
|
|
87
|
+
};
|
|
88
|
+
const resolvedBaseHeaders = typeof opts.baseHeaders === "function" ? await opts.baseHeaders() : opts.baseHeaders;
|
|
89
|
+
const headerValues = { ...typeof mergedClientOpts.headers === "function" ? await mergedClientOpts.headers() : mergedClientOpts.headers };
|
|
90
|
+
if (cType) headerValues["Content-Type"] = cType;
|
|
91
|
+
const finalHeaders = {};
|
|
92
|
+
if (resolvedBaseHeaders) {
|
|
93
|
+
for (const [key, value] of Object.entries(resolvedBaseHeaders)) if (value !== void 0) finalHeaders[key] = value;
|
|
94
|
+
}
|
|
95
|
+
Object.assign(finalHeaders, headerValues);
|
|
96
|
+
let url = opts.convexSiteUrl + path;
|
|
97
|
+
if (args.params) url = opts.convexSiteUrl + replaceUrlParam(path, args.params);
|
|
98
|
+
if (args.searchParams) {
|
|
99
|
+
const queryString = buildSearchParams(args.searchParams).toString();
|
|
100
|
+
if (queryString) url = `${url}?${queryString}`;
|
|
61
101
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
102
|
+
const methodUpperCase = method.toUpperCase();
|
|
103
|
+
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
104
|
+
const response = await (mergedClientOpts.fetch ?? opts.baseFetch ?? globalThis.fetch)(url, {
|
|
105
|
+
body: setBody ? rBody : void 0,
|
|
106
|
+
method: methodUpperCase,
|
|
107
|
+
headers: finalHeaders,
|
|
108
|
+
...mergedClientOpts.init
|
|
69
109
|
});
|
|
70
110
|
if (!response.ok) {
|
|
71
111
|
const errorData = await response.json().catch(() => ({ error: {
|
|
@@ -101,8 +141,8 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
101
141
|
if (prop === "queryOptions") {
|
|
102
142
|
if (!route) throw new Error(`Unknown HTTP procedure: ${routeKey}`);
|
|
103
143
|
if (route.method !== "GET") throw new Error(`queryOptions is only available for GET endpoints, got ${route.method} for ${routeKey}`);
|
|
104
|
-
return (args,
|
|
105
|
-
...
|
|
144
|
+
return (args, queryOpts) => ({
|
|
145
|
+
...queryOpts,
|
|
106
146
|
queryKey: [
|
|
107
147
|
"httpQuery",
|
|
108
148
|
routeKey,
|
|
@@ -114,9 +154,9 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
114
154
|
convexSiteUrl: opts.convexSiteUrl,
|
|
115
155
|
route,
|
|
116
156
|
procedureName: routeKey,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
157
|
+
args,
|
|
158
|
+
baseHeaders: opts.headers,
|
|
159
|
+
baseFetch: opts.fetch
|
|
120
160
|
});
|
|
121
161
|
} catch (error) {
|
|
122
162
|
if (opts.onError && error instanceof HttpClientError) opts.onError(error);
|
|
@@ -145,9 +185,8 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
145
185
|
};
|
|
146
186
|
if (prop === "mutationOptions") {
|
|
147
187
|
if (!route) throw new Error(`Unknown HTTP procedure: ${routeKey}`);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
...userOpts,
|
|
188
|
+
return (mutationOpts) => ({
|
|
189
|
+
...mutationOpts,
|
|
151
190
|
mutationKey: ["httpMutation", routeKey],
|
|
152
191
|
mutationFn: async (args) => {
|
|
153
192
|
try {
|
|
@@ -155,9 +194,9 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
155
194
|
convexSiteUrl: opts.convexSiteUrl,
|
|
156
195
|
route,
|
|
157
196
|
procedureName: routeKey,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
197
|
+
args,
|
|
198
|
+
baseHeaders: opts.headers,
|
|
199
|
+
baseFetch: opts.fetch
|
|
161
200
|
});
|
|
162
201
|
} catch (error) {
|
|
163
202
|
if (opts.onError && error instanceof HttpClientError) opts.onError(error);
|
package/dist/rsc/index.d.ts
CHANGED
|
@@ -1,14 +1,69 @@
|
|
|
1
|
-
import { E as HttpProcedure, U as UnsetMarker, f as DistributiveOmit, g as HttpRouterRecord, m as CRPCHttpRouter, p as Simplify } from "../http-types-
|
|
2
|
-
import { S as Meta, n as CRPCClient } from "../types-
|
|
1
|
+
import { E as HttpProcedure, U as UnsetMarker, f as DistributiveOmit, g as HttpRouterRecord, m as CRPCHttpRouter, p as Simplify } from "../http-types-B3tM9Old.js";
|
|
2
|
+
import { S as Meta, n as CRPCClient } from "../types-2L5nploW.js";
|
|
3
3
|
import { DefaultError, QueryFilters, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region src/react/http-proxy.d.ts
|
|
7
7
|
|
|
8
|
+
/** Form value types (matches Hono's FormValue) */
|
|
9
|
+
type HttpFormValue = string | Blob;
|
|
10
|
+
/**
|
|
11
|
+
* Hybrid input args: JSON body fields at root, explicit params/searchParams/form.
|
|
12
|
+
* - JSON body: spread at root level (tRPC-style)
|
|
13
|
+
* - Path params: { params: { id: '123' } }
|
|
14
|
+
* - Query params: { searchParams: { limit: '10' } }
|
|
15
|
+
* - Form data: { form: { file: blob } } - typed via .form() builder
|
|
16
|
+
* - Client options: { headers, fetch, init } - for per-call customization
|
|
17
|
+
*/
|
|
18
|
+
type HttpInputArgs = {
|
|
19
|
+
/** Path parameters (e.g., :id in /users/:id) */
|
|
20
|
+
params?: Record<string, string>;
|
|
21
|
+
/** Query string parameters */
|
|
22
|
+
searchParams?: Record<string, string | string[]>;
|
|
23
|
+
/** Form data body (Content-Type: multipart/form-data) - typed via .form() builder */
|
|
24
|
+
form?: Record<string, HttpFormValue | HttpFormValue[]>;
|
|
25
|
+
/** Custom fetch function (per-call override) */
|
|
26
|
+
fetch?: typeof fetch;
|
|
27
|
+
/** Standard RequestInit (per-call override) */
|
|
28
|
+
init?: RequestInit;
|
|
29
|
+
/** Additional headers (per-call override) */
|
|
30
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
31
|
+
/** Any other properties are JSON body fields */
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
8
34
|
/** Infer schema type or return empty object if UnsetMarker */
|
|
9
35
|
type InferSchemaOrEmpty<T> = T extends UnsetMarker ? object : T extends z.ZodTypeAny ? z.infer<T> : object;
|
|
10
|
-
/** Infer merged input from HttpProcedure */
|
|
36
|
+
/** Infer merged input from HttpProcedure (flat - used internally) */
|
|
11
37
|
type InferHttpInput<T> = T extends HttpProcedure<infer TInput, infer _TOutput, infer TParams, infer TQuery> ? Simplify<InferSchemaOrEmpty<TParams> & InferSchemaOrEmpty<TQuery> & InferSchemaOrEmpty<TInput>> : object;
|
|
38
|
+
/**
|
|
39
|
+
* Extract string keys from a Zod object schema.
|
|
40
|
+
* Used for param/query which are always strings in URLs.
|
|
41
|
+
*/
|
|
42
|
+
type ZodObjectKeys<T> = T extends z.ZodObject<infer Shape> ? { [K in keyof Shape]: string } : Record<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Extract string or string[] keys from a Zod object schema.
|
|
45
|
+
* Query params can have array values.
|
|
46
|
+
*/
|
|
47
|
+
type ZodQueryKeys<T> = T extends z.ZodObject<infer Shape> ? { [K in keyof Shape]?: string | string[] } : Record<string, string | string[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Infer client-side args from HttpProcedure with proper nesting.
|
|
50
|
+
* - params: only present if TParams is defined, always strings (URL path params)
|
|
51
|
+
* - searchParams: only present if TQuery is defined, always strings (URL query params)
|
|
52
|
+
* - form: only present if TForm is defined, typed from schema
|
|
53
|
+
* - JSON body fields spread at root level (typed from schema)
|
|
54
|
+
* - Client options (fetch, init, headers) always optional for per-call overrides
|
|
55
|
+
*/
|
|
56
|
+
type InferHttpClientArgs<T> = T extends HttpProcedure<infer TInput, infer _TOutput, infer TParams, infer TQuery, infer _TMethod, infer TForm> ? Simplify<(TParams extends UnsetMarker ? object : {
|
|
57
|
+
params: ZodObjectKeys<TParams>;
|
|
58
|
+
}) & (TQuery extends UnsetMarker ? object : {
|
|
59
|
+
searchParams: ZodQueryKeys<TQuery>;
|
|
60
|
+
}) & (TForm extends UnsetMarker ? object : TForm extends z.ZodTypeAny ? {
|
|
61
|
+
form: z.infer<TForm>;
|
|
62
|
+
} : object) & (TInput extends UnsetMarker ? object : TInput extends z.ZodTypeAny ? z.infer<TInput> : object) & {
|
|
63
|
+
fetch?: typeof fetch;
|
|
64
|
+
init?: RequestInit;
|
|
65
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
66
|
+
}> : HttpInputArgs;
|
|
12
67
|
/** Infer output type from HttpProcedure */
|
|
13
68
|
type InferHttpOutput<T> = T extends HttpProcedure<infer _TInput, infer TOutput, infer _TParams, infer _TQuery> ? TOutput extends UnsetMarker ? unknown : TOutput extends z.ZodTypeAny ? z.infer<TOutput> : unknown : unknown;
|
|
14
69
|
/** Query key with args (3-element) or prefix key without args (2-element) for invalidation */
|
|
@@ -16,25 +71,38 @@ type HttpQueryKey = readonly ['httpQuery', string, unknown] | readonly ['httpQue
|
|
|
16
71
|
type HttpMutationKey = readonly ['httpMutation', string];
|
|
17
72
|
type ReservedQueryOptions = 'queryKey' | 'queryFn';
|
|
18
73
|
type ReservedMutationOptions = 'mutationFn';
|
|
19
|
-
/** Variables type for mutations - void when no args required */
|
|
20
|
-
type HttpMutationVariables<T extends HttpProcedure> = keyof InferHttpInput<T> extends never ? void : object extends InferHttpInput<T> ? InferHttpInput<T> | undefined : InferHttpInput<T>;
|
|
21
74
|
/** Query options for GET HTTP endpoints - compatible with both useQuery and useSuspenseQuery */
|
|
22
75
|
type HttpQueryOptsReturn<T extends HttpProcedure> = Omit<UseQueryOptions<InferHttpOutput<T>, Error, InferHttpOutput<T>, HttpQueryKey>, 'queryFn'> & {
|
|
23
76
|
queryFn: () => Promise<InferHttpOutput<T>>;
|
|
24
77
|
};
|
|
25
|
-
/** Mutation options for POST/PUT/PATCH/DELETE HTTP endpoints */
|
|
26
|
-
type HttpMutationOptsReturn<T extends HttpProcedure> = UseMutationOptions<InferHttpOutput<T>, DefaultError,
|
|
27
|
-
/**
|
|
78
|
+
/** Mutation options for POST/PUT/PATCH/DELETE HTTP endpoints - typed variables */
|
|
79
|
+
type HttpMutationOptsReturn<T extends HttpProcedure> = UseMutationOptions<InferHttpOutput<T>, DefaultError, InferHttpClientArgs<T>>;
|
|
80
|
+
/** Query options (TanStack Query only - client opts go in args) */
|
|
81
|
+
type HttpQueryOptions<T extends HttpProcedure> = DistributiveOmit<HttpQueryOptsReturn<T>, ReservedQueryOptions>;
|
|
82
|
+
/** Mutation options (TanStack Query only - client opts go in mutate args) */
|
|
83
|
+
type HttpMutationOptions<T extends HttpProcedure> = DistributiveOmit<HttpMutationOptsReturn<T>, ReservedMutationOptions>;
|
|
84
|
+
/**
|
|
85
|
+
* Decorated GET procedure with queryOptions and mutationOptions.
|
|
86
|
+
* - queryOptions: For cached data fetching (useQuery/useSuspenseQuery)
|
|
87
|
+
* - mutationOptions: For one-time actions like exports (useMutation)
|
|
88
|
+
*/
|
|
28
89
|
type DecorateHttpQuery<T extends HttpProcedure> = {
|
|
29
|
-
queryOptions: keyof InferHttpInput<T> extends never ? (args?:
|
|
90
|
+
queryOptions: keyof InferHttpInput<T> extends never ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : object extends InferHttpInput<T> ? (args?: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T> : (args: InferHttpClientArgs<T>, opts?: HttpQueryOptions<T>) => HttpQueryOptsReturn<T>;
|
|
30
91
|
/** Get query key for QueryClient methods (with args = exact match, without = prefix) */
|
|
31
|
-
queryKey: (args?:
|
|
92
|
+
queryKey: (args?: InferHttpClientArgs<T>) => HttpQueryKey;
|
|
32
93
|
/** Get query filter for QueryClient methods (e.g., invalidateQueries) */
|
|
33
|
-
queryFilter: (args?:
|
|
94
|
+
queryFilter: (args?: InferHttpClientArgs<T>, filters?: DistributiveOmit<QueryFilters, 'queryKey'>) => QueryFilters;
|
|
95
|
+
/** Mutation options for GET endpoints (exports, downloads - no caching) */
|
|
96
|
+
mutationOptions: (opts?: HttpMutationOptions<T>) => HttpMutationOptsReturn<T>;
|
|
97
|
+
/** Get mutation key for QueryClient methods */
|
|
98
|
+
mutationKey: () => HttpMutationKey;
|
|
34
99
|
};
|
|
35
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Decorated POST/PUT/PATCH/DELETE procedure with mutationOptions.
|
|
102
|
+
* The mutationFn receives typed args inferred from server schemas.
|
|
103
|
+
*/
|
|
36
104
|
type DecorateHttpMutation<T extends HttpProcedure> = {
|
|
37
|
-
mutationOptions: (opts?:
|
|
105
|
+
mutationOptions: (opts?: HttpMutationOptions<T>) => HttpMutationOptsReturn<T>;
|
|
38
106
|
/** Get mutation key for QueryClient methods */
|
|
39
107
|
mutationKey: () => HttpMutationKey;
|
|
40
108
|
};
|
|
@@ -43,7 +111,7 @@ type DecorateHttpMutation<T extends HttpProcedure> = {
|
|
|
43
111
|
* Maps each procedure to queryOptions (GET) or mutationOptions (POST/etc).
|
|
44
112
|
* Uses infer to extract the method type literal for proper GET/non-GET distinction.
|
|
45
113
|
*/
|
|
46
|
-
type HttpCRPCClient<T extends HttpRouterRecord> = { [K in keyof T]: T[K] extends HttpProcedure<infer _TInput, infer _TOutput, infer _TParams, infer _TQuery, infer TMethod> ? TMethod extends 'GET' ? DecorateHttpQuery<T[K]> : DecorateHttpMutation<T[K]> : T[K] extends CRPCHttpRouter<infer R> ? HttpCRPCClient<R> : T[K] extends HttpRouterRecord ? HttpCRPCClient<T[K]> : never };
|
|
114
|
+
type HttpCRPCClient<T extends HttpRouterRecord> = { [K in keyof T]: T[K] extends HttpProcedure<infer _TInput, infer _TOutput, infer _TParams, infer _TQuery, infer TMethod, infer _TForm> ? TMethod extends 'GET' ? DecorateHttpQuery<T[K]> : DecorateHttpMutation<T[K]> : T[K] extends CRPCHttpRouter<infer R> ? HttpCRPCClient<R> : T[K] extends HttpRouterRecord ? HttpCRPCClient<T[K]> : never };
|
|
47
115
|
/**
|
|
48
116
|
* HTTP Client type from a CRPCHttpRouter.
|
|
49
117
|
* Use this when your type is the router object (with _def).
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as ProcedureMeta, B as Overwrite, C as HttpActionHandler, D as HttpProcedureBuilderDef, E as HttpProcedure, F as MiddlewareBuilder, H as Simplify, I as MiddlewareFunction, L as MiddlewareMarker, M as AnyMiddlewareBuilder, N as IntersectIfDefined, O as HttpRouteDefinition, P as MergeZodObjects, R as MiddlewareNext, S as HttpActionConstructor, T as HttpMethod, U as UnsetMarker, V as ResolveIfSet, _ as HttpRouterWithHono, b as extractRouteMap, c as InferHttpInput$1, g as HttpRouterRecord, h as HttpRouterDef, j as AnyMiddleware, k as InferHttpInput, l as InferHttpOutput, m as CRPCHttpRouter, v as createHttpRouter, w as HttpHandlerOpts, x as CRPCHonoHandler, y as createHttpRouterFactory, z as MiddlewareResult } from "../http-types-
|
|
1
|
+
import { A as ProcedureMeta, B as Overwrite, C as HttpActionHandler, D as HttpProcedureBuilderDef, E as HttpProcedure, F as MiddlewareBuilder, H as Simplify, I as MiddlewareFunction, L as MiddlewareMarker, M as AnyMiddlewareBuilder, N as IntersectIfDefined, O as HttpRouteDefinition, P as MergeZodObjects, R as MiddlewareNext, S as HttpActionConstructor, T as HttpMethod, U as UnsetMarker, V as ResolveIfSet, _ as HttpRouterWithHono, b as extractRouteMap, c as InferHttpInput$1, g as HttpRouterRecord, h as HttpRouterDef, j as AnyMiddleware, k as InferHttpInput, l as InferHttpOutput, m as CRPCHttpRouter, v as createHttpRouter, w as HttpHandlerOpts, x as CRPCHonoHandler, y as createHttpRouterFactory, z as MiddlewareResult } from "../http-types-B3tM9Old.js";
|
|
2
2
|
import * as convex_server30 from "convex/server";
|
|
3
3
|
import { FunctionReference, FunctionReturnType, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx } from "convex/server";
|
|
4
4
|
import { EmptyObject } from "convex-helpers";
|
|
@@ -18,53 +18,55 @@ declare function handleHttpError(error: unknown): Response;
|
|
|
18
18
|
* - Factory function creates implementation objects
|
|
19
19
|
* - This preserves literal types like 'GET' through method chains
|
|
20
20
|
*/
|
|
21
|
-
interface HttpProcedureBuilder<TInitialCtx, TCtx, TInput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TParams extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TQuery extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends ProcedureMeta = ProcedureMeta, TMethod extends HttpMethod = HttpMethod> {
|
|
22
|
-
_def: HttpProcedureBuilderDef<TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod>;
|
|
21
|
+
interface HttpProcedureBuilder<TInitialCtx, TCtx, TInput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TParams extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TQuery extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends ProcedureMeta = ProcedureMeta, TMethod extends HttpMethod = HttpMethod, TForm extends UnsetMarker | z.ZodTypeAny = UnsetMarker> {
|
|
22
|
+
_def: HttpProcedureBuilderDef<TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
|
|
23
23
|
/** Add middleware to the procedure */
|
|
24
|
-
use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<TCtx, TMeta, UnsetMarker, $ContextOverridesOut> | MiddlewareBuilder<TInitialCtx, TMeta, $ContextOverridesOut>): HttpProcedureBuilder<TInitialCtx, Overwrite<TCtx, $ContextOverridesOut>, TInput, TOutput, TParams, TQuery, TMeta, TMethod>;
|
|
24
|
+
use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<TCtx, TMeta, UnsetMarker, $ContextOverridesOut> | MiddlewareBuilder<TInitialCtx, TMeta, $ContextOverridesOut>): HttpProcedureBuilder<TInitialCtx, Overwrite<TCtx, $ContextOverridesOut>, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
|
|
25
25
|
/** Set procedure metadata (shallow merged when chained) */
|
|
26
|
-
meta(value: TMeta): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod>;
|
|
26
|
+
meta(value: TMeta): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
|
|
27
27
|
/** Define the route path and HTTP method */
|
|
28
|
-
route<M extends HttpMethod>(path: string, method: M): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, M>;
|
|
28
|
+
route<M extends HttpMethod>(path: string, method: M): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, M, TForm>;
|
|
29
29
|
/** GET endpoint (Hono-style) */
|
|
30
|
-
get(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'GET'>;
|
|
30
|
+
get(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'GET', TForm>;
|
|
31
31
|
/** POST endpoint (Hono-style) */
|
|
32
|
-
post(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'POST'>;
|
|
32
|
+
post(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'POST', TForm>;
|
|
33
33
|
/** PUT endpoint (Hono-style) */
|
|
34
|
-
put(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PUT'>;
|
|
34
|
+
put(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PUT', TForm>;
|
|
35
35
|
/** PATCH endpoint (Hono-style) */
|
|
36
|
-
patch(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PATCH'>;
|
|
36
|
+
patch(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'PATCH', TForm>;
|
|
37
37
|
/** DELETE endpoint (Hono-style) */
|
|
38
|
-
delete(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'DELETE'>;
|
|
38
|
+
delete(path: string): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, 'DELETE', TForm>;
|
|
39
39
|
/** Define path parameter schema (for :param in path) */
|
|
40
|
-
params<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TSchema, TQuery, TMeta, TMethod>;
|
|
40
|
+
params<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TSchema, TQuery, TMeta, TMethod, TForm>;
|
|
41
41
|
/** Define query parameter schema (?key=value) */
|
|
42
|
-
searchParams<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TSchema, TMeta, TMethod>;
|
|
42
|
+
searchParams<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TSchema, TMeta, TMethod, TForm>;
|
|
43
43
|
/** Define request body schema (for POST/PUT/PATCH) */
|
|
44
|
-
input<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TSchema, TOutput, TParams, TQuery, TMeta, TMethod>;
|
|
44
|
+
input<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TSchema, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
|
|
45
45
|
/** Define response schema */
|
|
46
|
-
output<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TSchema, TParams, TQuery, TMeta, TMethod>;
|
|
46
|
+
output<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TSchema, TParams, TQuery, TMeta, TMethod, TForm>;
|
|
47
|
+
/** Define form data schema (for multipart/form-data uploads) */
|
|
48
|
+
form<TSchema extends z.ZodTypeAny>(schema: TSchema): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TSchema>;
|
|
47
49
|
/**
|
|
48
50
|
* Define the handler for GET endpoints (maps to useQuery on client).
|
|
49
51
|
* Handler receives Hono Context `c` for Response helpers (c.json, c.body, c.text).
|
|
50
52
|
* Return Response for custom responses, or plain object for auto JSON serialization.
|
|
51
53
|
*/
|
|
52
|
-
query<TResult>(handler: (opts: HttpHandlerOpts<TCtx, TInput, TParams, TQuery>) => Promise<Response | (TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult)>): HttpProcedure<TInput, TOutput, TParams, TQuery, TMethod>;
|
|
54
|
+
query<TResult>(handler: (opts: HttpHandlerOpts<TCtx, TInput, TParams, TQuery, TForm>) => Promise<Response | (TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult)>): HttpProcedure<TInput, TOutput, TParams, TQuery, TMethod, TForm>;
|
|
53
55
|
/**
|
|
54
56
|
* Define the handler for POST/PUT/PATCH/DELETE endpoints (maps to useMutation on client).
|
|
55
57
|
* Handler receives Hono Context `c` for Response helpers (c.json, c.body, c.text).
|
|
56
58
|
* Return Response for custom responses, or plain object for auto JSON serialization.
|
|
57
59
|
*/
|
|
58
|
-
mutation<TResult>(handler: (opts: HttpHandlerOpts<TCtx, TInput, TParams, TQuery>) => Promise<Response | (TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult)>): HttpProcedure<TInput, TOutput, TParams, TQuery, TMethod>;
|
|
60
|
+
mutation<TResult>(handler: (opts: HttpHandlerOpts<TCtx, TInput, TParams, TQuery, TForm>) => Promise<Response | (TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult)>): HttpProcedure<TInput, TOutput, TParams, TQuery, TMethod, TForm>;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Create initial HttpProcedureBuilder
|
|
62
64
|
*/
|
|
63
65
|
declare function createHttpProcedureBuilder<TCtx, TMeta extends ProcedureMeta>(config: {
|
|
64
|
-
base: HttpProcedureBuilderDef<TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod>['functionConfig']['base'];
|
|
66
|
+
base: HttpProcedureBuilderDef<TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod, UnsetMarker>['functionConfig']['base'];
|
|
65
67
|
createContext: (ctx: GenericActionCtx<GenericDataModel>) => TCtx;
|
|
66
68
|
meta: TMeta;
|
|
67
|
-
}): HttpProcedureBuilder<TCtx, TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod>;
|
|
69
|
+
}): HttpProcedureBuilder<TCtx, TCtx, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, TMeta, HttpMethod, UnsetMarker>;
|
|
68
70
|
//#endregion
|
|
69
71
|
//#region src/server/builder.d.ts
|
|
70
72
|
/**
|
package/dist/server/index.js
CHANGED
|
@@ -239,13 +239,21 @@ function createProcedure(def, handler, _type) {
|
|
|
239
239
|
} else body = await request.json().catch(() => ({}));
|
|
240
240
|
parsedInput = def.inputSchema.parse(body);
|
|
241
241
|
}
|
|
242
|
+
let parsedForm;
|
|
243
|
+
if (def.formSchema && request.method !== "GET") {
|
|
244
|
+
const formData = await request.formData();
|
|
245
|
+
const formObj = {};
|
|
246
|
+
for (const [key, value] of formData.entries()) formObj[key] = value;
|
|
247
|
+
parsedForm = def.formSchema.parse(formObj);
|
|
248
|
+
}
|
|
242
249
|
const handlerOpts = {
|
|
243
250
|
ctx,
|
|
244
251
|
c
|
|
245
252
|
};
|
|
246
253
|
if (parsedInput !== void 0) handlerOpts.input = parsedInput;
|
|
247
254
|
if (parsedParams !== void 0) handlerOpts.params = parsedParams;
|
|
248
|
-
if (parsedQuery !== void 0) handlerOpts.
|
|
255
|
+
if (parsedQuery !== void 0) handlerOpts.searchParams = parsedQuery;
|
|
256
|
+
if (parsedForm !== void 0) handlerOpts.form = parsedForm;
|
|
249
257
|
const result = await handler(handlerOpts);
|
|
250
258
|
if (result instanceof Response) return result;
|
|
251
259
|
const output = def.outputSchema ? def.outputSchema.parse(result) : result;
|
|
@@ -282,7 +290,8 @@ function createProcedure(def, handler, _type) {
|
|
|
282
290
|
inputSchema: def.inputSchema,
|
|
283
291
|
outputSchema: def.outputSchema,
|
|
284
292
|
paramsSchema: def.paramsSchema,
|
|
285
|
-
querySchema: def.querySchema
|
|
293
|
+
querySchema: def.querySchema,
|
|
294
|
+
formSchema: def.formSchema
|
|
286
295
|
};
|
|
287
296
|
procedure._honoHandler = honoHandler;
|
|
288
297
|
return procedure;
|
|
@@ -367,6 +376,9 @@ function createHttpBuilder(def) {
|
|
|
367
376
|
output(schema) {
|
|
368
377
|
return createNewHttpBuilder(def, { outputSchema: schema });
|
|
369
378
|
},
|
|
379
|
+
form(schema) {
|
|
380
|
+
return createNewHttpBuilder(def, { formSchema: schema });
|
|
381
|
+
},
|
|
370
382
|
query(handler) {
|
|
371
383
|
return createProcedure(def, handler, "query");
|
|
372
384
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as DeepPartial, f as DistributiveOmit, p as Simplify } from "./http-types-
|
|
1
|
+
import { d as DeepPartial, f as DistributiveOmit, p as Simplify } from "./http-types-B3tM9Old.js";
|
|
2
2
|
import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
|
|
3
3
|
import { DefaultError, QueryFilters, SkipToken, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
|