better-convex 0.5.0 → 0.5.1
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 +60 -60
- package/dist/auth-nextjs/index.d.ts +1 -1
- package/dist/crpc/index.d.ts +2 -2
- package/dist/{http-types-B3tM9Old.d.ts → http-types-DAM81UvD.d.ts} +29 -12
- package/dist/rsc/index.d.ts +2 -2
- package/dist/server/index.d.ts +27 -14
- package/dist/server/index.js +47 -18
- package/dist/{types-DMJsgCiw.d.ts → types-CozLu-ht.d.ts} +1 -1
- package/package.json +1 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as better_auth_adapters1 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_server24 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";
|
|
@@ -48,28 +48,28 @@ declare const createClient: <DataModel extends GenericDataModel, Schema$1 extend
|
|
|
48
48
|
adapter: (ctx: GenericCtx<DataModel>, createAuthOptions: (ctx: any) => BetterAuthOptions) => better_auth_adapters1.AdapterFactory;
|
|
49
49
|
httpAdapter: (ctx: GenericCtx<DataModel>) => better_auth_adapters1.AdapterFactory;
|
|
50
50
|
triggersApi: () => {
|
|
51
|
-
beforeCreate:
|
|
51
|
+
beforeCreate: convex_server24.RegisteredMutation<"internal", {
|
|
52
52
|
data: any;
|
|
53
53
|
model: string;
|
|
54
54
|
}, Promise<any>>;
|
|
55
|
-
beforeDelete:
|
|
55
|
+
beforeDelete: convex_server24.RegisteredMutation<"internal", {
|
|
56
56
|
model: string;
|
|
57
57
|
doc: any;
|
|
58
58
|
}, Promise<any>>;
|
|
59
|
-
beforeUpdate:
|
|
59
|
+
beforeUpdate: convex_server24.RegisteredMutation<"internal", {
|
|
60
60
|
update: any;
|
|
61
61
|
model: string;
|
|
62
62
|
doc: any;
|
|
63
63
|
}, Promise<any>>;
|
|
64
|
-
onCreate:
|
|
64
|
+
onCreate: convex_server24.RegisteredMutation<"internal", {
|
|
65
65
|
model: string;
|
|
66
66
|
doc: any;
|
|
67
67
|
}, Promise<void>>;
|
|
68
|
-
onDelete:
|
|
68
|
+
onDelete: convex_server24.RegisteredMutation<"internal", {
|
|
69
69
|
model: string;
|
|
70
70
|
doc: any;
|
|
71
71
|
}, Promise<void>>;
|
|
72
|
-
onUpdate:
|
|
72
|
+
onUpdate: convex_server24.RegisteredMutation<"internal", {
|
|
73
73
|
model: string;
|
|
74
74
|
newDoc: any;
|
|
75
75
|
oldDoc: any;
|
|
@@ -164,20 +164,20 @@ declare const dbAdapter: <DataModel extends GenericDataModel, Schema$1 extends S
|
|
|
164
164
|
//#endregion
|
|
165
165
|
//#region src/auth/adapter-utils.d.ts
|
|
166
166
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
167
|
-
operator?: "
|
|
167
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
168
168
|
connector?: "AND" | "OR" | undefined;
|
|
169
169
|
value: string | number | boolean | string[] | number[] | null;
|
|
170
170
|
field: string;
|
|
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<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "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", "operator" | "value" | "field" | "connector">;
|
|
177
177
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
178
178
|
limit?: number | undefined;
|
|
179
179
|
where?: {
|
|
180
|
-
operator?: "
|
|
180
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
181
181
|
connector?: "AND" | "OR" | undefined;
|
|
182
182
|
value: string | number | boolean | string[] | number[] | null;
|
|
183
183
|
field: string;
|
|
@@ -202,21 +202,21 @@ 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?: "
|
|
205
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
206
206
|
connector?: "AND" | "OR" | undefined;
|
|
207
207
|
value: string | number | boolean | string[] | number[] | null;
|
|
208
208
|
field: string;
|
|
209
209
|
}[] | undefined, convex_values0.VObject<{
|
|
210
|
-
operator?: "
|
|
210
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
211
211
|
connector?: "AND" | "OR" | undefined;
|
|
212
212
|
value: string | number | boolean | string[] | number[] | null;
|
|
213
213
|
field: string;
|
|
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<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "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", "
|
|
219
|
+
}, "required", "operator" | "value" | "field" | "connector">, "optional">;
|
|
220
220
|
}, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "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>;
|
|
@@ -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_server24.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_server24.PaginationResult<convex_server24.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_server24.Cursor;
|
|
283
|
+
splitCursor?: convex_server24.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_server24.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_server24.Cursor;
|
|
309
|
+
splitCursor?: convex_server24.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,7 +314,7 @@ 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_server24.RegisteredMutation<"internal", {
|
|
318
318
|
select?: string[] | undefined;
|
|
319
319
|
beforeCreateHandle?: string | undefined;
|
|
320
320
|
onCreateHandle?: string | undefined;
|
|
@@ -330,38 +330,38 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
330
330
|
model: string;
|
|
331
331
|
};
|
|
332
332
|
}, Promise<any>>;
|
|
333
|
-
deleteMany:
|
|
333
|
+
deleteMany: convex_server24.RegisteredMutation<"internal", {
|
|
334
334
|
beforeDeleteHandle?: string | undefined;
|
|
335
335
|
onDeleteHandle?: string | undefined;
|
|
336
|
+
paginationOpts: {
|
|
337
|
+
id?: number;
|
|
338
|
+
endCursor?: string | null;
|
|
339
|
+
maximumRowsRead?: number;
|
|
340
|
+
maximumBytesRead?: number;
|
|
341
|
+
numItems: number;
|
|
342
|
+
cursor: string | null;
|
|
343
|
+
};
|
|
336
344
|
input: {
|
|
337
345
|
where?: any[] | undefined;
|
|
338
346
|
model: string;
|
|
339
347
|
} | {
|
|
340
348
|
where?: {
|
|
341
|
-
operator?: "
|
|
349
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
342
350
|
connector?: "AND" | "OR" | undefined;
|
|
343
351
|
value: string | number | boolean | string[] | number[] | null;
|
|
344
352
|
field: string;
|
|
345
353
|
}[] | undefined;
|
|
346
354
|
model: string;
|
|
347
355
|
};
|
|
348
|
-
paginationOpts: {
|
|
349
|
-
id?: number;
|
|
350
|
-
endCursor?: string | null;
|
|
351
|
-
maximumRowsRead?: number;
|
|
352
|
-
maximumBytesRead?: number;
|
|
353
|
-
numItems: number;
|
|
354
|
-
cursor: string | null;
|
|
355
|
-
};
|
|
356
356
|
}, Promise<{
|
|
357
357
|
count: number;
|
|
358
358
|
ids: any[];
|
|
359
359
|
isDone: boolean;
|
|
360
|
-
continueCursor:
|
|
361
|
-
splitCursor?:
|
|
360
|
+
continueCursor: convex_server24.Cursor;
|
|
361
|
+
splitCursor?: convex_server24.Cursor | null;
|
|
362
362
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
363
363
|
}>>;
|
|
364
|
-
deleteOne:
|
|
364
|
+
deleteOne: convex_server24.RegisteredMutation<"internal", {
|
|
365
365
|
beforeDeleteHandle?: string | undefined;
|
|
366
366
|
onDeleteHandle?: string | undefined;
|
|
367
367
|
input: {
|
|
@@ -369,19 +369,19 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
369
369
|
model: string;
|
|
370
370
|
} | {
|
|
371
371
|
where?: {
|
|
372
|
-
operator?: "
|
|
372
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
373
373
|
connector?: "AND" | "OR" | undefined;
|
|
374
374
|
value: string | number | boolean | string[] | number[] | null;
|
|
375
375
|
field: string;
|
|
376
376
|
}[] | undefined;
|
|
377
377
|
model: string;
|
|
378
378
|
};
|
|
379
|
-
}, Promise<
|
|
380
|
-
findMany:
|
|
379
|
+
}, Promise<convex_server24.GenericDocument | undefined>>;
|
|
380
|
+
findMany: convex_server24.RegisteredQuery<"internal", {
|
|
381
381
|
limit?: number | undefined;
|
|
382
382
|
join?: any;
|
|
383
383
|
where?: {
|
|
384
|
-
operator?: "
|
|
384
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
385
385
|
connector?: "AND" | "OR" | undefined;
|
|
386
386
|
value: string | number | boolean | string[] | number[] | null;
|
|
387
387
|
field: string;
|
|
@@ -400,28 +400,36 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
400
400
|
cursor: string | null;
|
|
401
401
|
};
|
|
402
402
|
model: string;
|
|
403
|
-
}, Promise<
|
|
404
|
-
findOne:
|
|
403
|
+
}, Promise<convex_server24.PaginationResult<convex_server24.GenericDocument>>>;
|
|
404
|
+
findOne: convex_server24.RegisteredQuery<"internal", {
|
|
405
405
|
join?: any;
|
|
406
406
|
where?: {
|
|
407
|
-
operator?: "
|
|
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
|
value: string | number | boolean | string[] | number[] | null;
|
|
410
410
|
field: string;
|
|
411
411
|
}[] | undefined;
|
|
412
412
|
select?: string[] | undefined;
|
|
413
413
|
model: string;
|
|
414
|
-
}, Promise<
|
|
415
|
-
updateMany:
|
|
414
|
+
}, Promise<convex_server24.GenericDocument | null>>;
|
|
415
|
+
updateMany: convex_server24.RegisteredMutation<"internal", {
|
|
416
416
|
beforeUpdateHandle?: string | undefined;
|
|
417
417
|
onUpdateHandle?: string | undefined;
|
|
418
|
+
paginationOpts: {
|
|
419
|
+
id?: number;
|
|
420
|
+
endCursor?: string | null;
|
|
421
|
+
maximumRowsRead?: number;
|
|
422
|
+
maximumBytesRead?: number;
|
|
423
|
+
numItems: number;
|
|
424
|
+
cursor: string | null;
|
|
425
|
+
};
|
|
418
426
|
input: {
|
|
419
427
|
where?: any[] | undefined;
|
|
420
428
|
update: any;
|
|
421
429
|
model: string;
|
|
422
430
|
} | {
|
|
423
431
|
where?: {
|
|
424
|
-
operator?: "
|
|
432
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
425
433
|
connector?: "AND" | "OR" | undefined;
|
|
426
434
|
value: string | number | boolean | string[] | number[] | null;
|
|
427
435
|
field: string;
|
|
@@ -433,23 +441,15 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
433
441
|
};
|
|
434
442
|
model: string;
|
|
435
443
|
};
|
|
436
|
-
paginationOpts: {
|
|
437
|
-
id?: number;
|
|
438
|
-
endCursor?: string | null;
|
|
439
|
-
maximumRowsRead?: number;
|
|
440
|
-
maximumBytesRead?: number;
|
|
441
|
-
numItems: number;
|
|
442
|
-
cursor: string | null;
|
|
443
|
-
};
|
|
444
444
|
}, Promise<{
|
|
445
445
|
count: number;
|
|
446
446
|
ids: any[];
|
|
447
447
|
isDone: boolean;
|
|
448
|
-
continueCursor:
|
|
449
|
-
splitCursor?:
|
|
448
|
+
continueCursor: convex_server24.Cursor;
|
|
449
|
+
splitCursor?: convex_server24.Cursor | null;
|
|
450
450
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
451
451
|
}>>;
|
|
452
|
-
updateOne:
|
|
452
|
+
updateOne: convex_server24.RegisteredMutation<"internal", {
|
|
453
453
|
beforeUpdateHandle?: string | undefined;
|
|
454
454
|
onUpdateHandle?: string | undefined;
|
|
455
455
|
input: {
|
|
@@ -458,7 +458,7 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
458
458
|
model: string;
|
|
459
459
|
} | {
|
|
460
460
|
where?: {
|
|
461
|
-
operator?: "
|
|
461
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
462
462
|
connector?: "AND" | "OR" | undefined;
|
|
463
463
|
value: string | number | boolean | string[] | number[] | null;
|
|
464
464
|
field: string;
|
|
@@ -471,8 +471,8 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
471
471
|
model: string;
|
|
472
472
|
};
|
|
473
473
|
}, Promise<any>>;
|
|
474
|
-
getLatestJwks:
|
|
475
|
-
rotateKeys:
|
|
474
|
+
getLatestJwks: convex_server24.RegisteredAction<"internal", {}, Promise<any>>;
|
|
475
|
+
rotateKeys: convex_server24.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, D as VanillaMutation, E as VanillaCRPCClient, O as VanillaQuery, S as Meta, T as VanillaAction, _ 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-DAM81UvD.js";
|
|
2
|
+
import { C as PaginatedFnMeta, D as VanillaMutation, E as VanillaCRPCClient, O as VanillaQuery, S as Meta, T as VanillaAction, _ 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-CozLu-ht.js";
|
|
3
3
|
import { FunctionArgs, FunctionReference } from "convex/server";
|
|
4
4
|
|
|
5
5
|
//#region src/crpc/error.d.ts
|
|
@@ -40,39 +40,56 @@ type MiddlewareResult<TContext> = {
|
|
|
40
40
|
readonly marker: MiddlewareMarker;
|
|
41
41
|
ctx: TContext;
|
|
42
42
|
};
|
|
43
|
-
/**
|
|
43
|
+
/** Function to get raw input before validation */
|
|
44
|
+
type GetRawInputFn = () => Promise<unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Next function overloads - key to automatic context and input inference
|
|
47
|
+
* Matches tRPC's pattern: can modify context, input, or both
|
|
48
|
+
*/
|
|
44
49
|
type MiddlewareNext<TContextOverridesIn> = {
|
|
45
50
|
/** Continue without modification - passes through existing overrides */
|
|
46
51
|
(): Promise<MiddlewareResult<TContextOverridesIn>>;
|
|
47
|
-
/** Continue with modified context
|
|
52
|
+
/** Continue with modified context and/or input */
|
|
48
53
|
<$ContextOverride>(opts: {
|
|
49
|
-
ctx
|
|
54
|
+
ctx?: $ContextOverride;
|
|
55
|
+
input?: unknown;
|
|
50
56
|
}): Promise<MiddlewareResult<$ContextOverride>>;
|
|
51
57
|
};
|
|
52
58
|
/**
|
|
53
|
-
* Middleware function signature
|
|
54
|
-
*
|
|
59
|
+
* Middleware function signature with input access (tRPC-compatible)
|
|
60
|
+
*
|
|
61
|
+
* @typeParam TContext - Base context type
|
|
62
|
+
* @typeParam TMeta - Procedure metadata type
|
|
63
|
+
* @typeParam TContextOverridesIn - Context overrides from previous middleware
|
|
64
|
+
* @typeParam $ContextOverridesOut - Context overrides this middleware adds (inferred from next())
|
|
65
|
+
* @typeParam TInputOut - Parsed input type (unknown if before .input(), typed if after)
|
|
55
66
|
*/
|
|
56
|
-
type MiddlewareFunction<TContext, TMeta, TContextOverridesIn, $ContextOverridesOut> = (opts: {
|
|
67
|
+
type MiddlewareFunction<TContext, TMeta, TContextOverridesIn, $ContextOverridesOut, TInputOut = unknown> = (opts: {
|
|
57
68
|
ctx: Simplify$1<Overwrite<TContext, TContextOverridesIn>>;
|
|
58
69
|
meta: TMeta;
|
|
70
|
+
input: TInputOut;
|
|
71
|
+
getRawInput: GetRawInputFn;
|
|
59
72
|
next: MiddlewareNext<TContextOverridesIn>;
|
|
60
73
|
}) => Promise<MiddlewareResult<$ContextOverridesOut>>;
|
|
61
74
|
/** Stored middleware with type info erased for runtime */
|
|
62
|
-
type AnyMiddleware = MiddlewareFunction<any, any, any, any>;
|
|
75
|
+
type AnyMiddleware = MiddlewareFunction<any, any, any, any, any>;
|
|
63
76
|
/**
|
|
64
77
|
* Middleware builder for creating reusable, composable middleware chains
|
|
65
78
|
* Similar to tRPC's MiddlewareBuilder
|
|
66
|
-
*
|
|
79
|
+
*
|
|
80
|
+
* @typeParam TContext - Base context type
|
|
81
|
+
* @typeParam TMeta - Procedure metadata type
|
|
82
|
+
* @typeParam $ContextOverridesOut - Accumulated context overrides
|
|
83
|
+
* @typeParam TInputOut - Input type this middleware chain expects
|
|
67
84
|
*/
|
|
68
|
-
type MiddlewareBuilder<
|
|
85
|
+
type MiddlewareBuilder<TContext, TMeta, $ContextOverridesOut, TInputOut = unknown> = {
|
|
69
86
|
/** Internal array of middleware functions */
|
|
70
87
|
_middlewares: AnyMiddleware[];
|
|
71
88
|
/** Chain another middleware to this builder */
|
|
72
|
-
pipe<$NewContextOverrides>(fn: MiddlewareFunction<TContext, TMeta, $ContextOverridesOut, $NewContextOverrides>): MiddlewareBuilder<TContext, TMeta, Overwrite<$ContextOverridesOut, $NewContextOverrides
|
|
89
|
+
pipe<$NewContextOverrides>(fn: MiddlewareFunction<TContext, TMeta, $ContextOverridesOut, $NewContextOverrides, TInputOut>): MiddlewareBuilder<TContext, TMeta, Overwrite<$ContextOverridesOut, $NewContextOverrides>, TInputOut>;
|
|
73
90
|
};
|
|
74
91
|
/** Type-erased middleware builder for runtime */
|
|
75
|
-
type AnyMiddlewareBuilder = MiddlewareBuilder<any, any, any>;
|
|
92
|
+
type AnyMiddlewareBuilder = MiddlewareBuilder<any, any, any, any>;
|
|
76
93
|
//#endregion
|
|
77
94
|
//#region src/server/http-types.d.ts
|
|
78
95
|
type ProcedureMeta = object;
|
|
@@ -310,4 +327,4 @@ declare class HttpClientError extends Error {
|
|
|
310
327
|
/** Type guard for HttpClientError */
|
|
311
328
|
declare const isHttpClientError: (error: unknown) => error is HttpClientError;
|
|
312
329
|
//#endregion
|
|
313
|
-
export { ProcedureMeta as A,
|
|
330
|
+
export { ProcedureMeta as A, MiddlewareResult as B, HttpActionHandler as C, HttpProcedureBuilderDef as D, HttpProcedure as E, MergeZodObjects as F, ResolveIfSet as H, MiddlewareBuilder as I, MiddlewareFunction as L, AnyMiddlewareBuilder as M, GetRawInputFn as N, HttpRouteDefinition as O, IntersectIfDefined as P, MiddlewareMarker as R, HttpActionConstructor as S, HttpMethod as T, Simplify$1 as U, Overwrite as V, UnsetMarker as W, HttpRouterWithHono as _, HttpProcedureCall as a, extractRouteMap as b, InferHttpInput as c, DeepPartial as d, DistributiveOmit as f, HttpRouterRecord as g, HttpRouterDef as h, HttpErrorCode as i, AnyMiddleware as j, InferHttpInput$1 as k, InferHttpOutput as l, CRPCHttpRouter as m, HttpClientError as n, HttpRouteInfo as o, Simplify as p, HttpClientFromRouter as r, HttpRouteMap as s, HttpClient as t, isHttpClientError as u, createHttpRouter as v, HttpHandlerOpts as w, CRPCHonoHandler as x, createHttpRouterFactory as y, MiddlewareNext as z };
|
package/dist/rsc/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as HttpProcedure,
|
|
2
|
-
import { S as Meta, n as CRPCClient } from "../types-
|
|
1
|
+
import { E as HttpProcedure, W as UnsetMarker, f as DistributiveOmit, g as HttpRouterRecord, m as CRPCHttpRouter, p as Simplify } from "../http-types-DAM81UvD.js";
|
|
2
|
+
import { S as Meta, n as CRPCClient } from "../types-CozLu-ht.js";
|
|
3
3
|
import { DefaultError, QueryFilters, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ProcedureMeta, B as
|
|
2
|
-
import * as
|
|
1
|
+
import { A as ProcedureMeta, B as MiddlewareResult, C as HttpActionHandler, D as HttpProcedureBuilderDef, E as HttpProcedure, F as MergeZodObjects, H as ResolveIfSet, I as MiddlewareBuilder, L as MiddlewareFunction, M as AnyMiddlewareBuilder, N as GetRawInputFn, O as HttpRouteDefinition, P as IntersectIfDefined, R as MiddlewareMarker, S as HttpActionConstructor, T as HttpMethod, U as Simplify, V as Overwrite, W as UnsetMarker, _ 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 MiddlewareNext } from "../http-types-DAM81UvD.js";
|
|
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";
|
|
5
5
|
import { ConvexError } from "convex/values";
|
|
@@ -21,7 +21,7 @@ declare function handleHttpError(error: unknown): Response;
|
|
|
21
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
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, TForm>;
|
|
24
|
+
use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<TCtx, TMeta, UnsetMarker, $ContextOverridesOut, unknown> | MiddlewareBuilder<TInitialCtx, TMeta, $ContextOverridesOut, unknown>): HttpProcedureBuilder<TInitialCtx, Overwrite<TCtx, $ContextOverridesOut>, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
|
|
25
25
|
/** Set procedure metadata (shallow merged when chained) */
|
|
26
26
|
meta(value: TMeta): HttpProcedureBuilder<TInitialCtx, TCtx, TInput, TOutput, TParams, TQuery, TMeta, TMethod, TForm>;
|
|
27
27
|
/** Define the route path and HTTP method */
|
|
@@ -81,9 +81,14 @@ declare const paginatedSchemaForTypes: z.ZodObject<{
|
|
|
81
81
|
/** Paginated schema type - both cursor and limit are required after .paginated() */
|
|
82
82
|
type PaginatedInputSchema = typeof paginatedSchemaForTypes;
|
|
83
83
|
/**
|
|
84
|
-
* Infer input type from ZodObject schema
|
|
84
|
+
* Infer input type from ZodObject schema (for handlers)
|
|
85
85
|
*/
|
|
86
86
|
type InferInput<T> = T extends UnsetMarker ? Record<string, never> : T extends z.ZodObject<any> ? z.infer<T> : never;
|
|
87
|
+
/**
|
|
88
|
+
* Infer input type for middleware (returns unknown for UnsetMarker, matching tRPC)
|
|
89
|
+
* Middleware before .input() receives unknown input
|
|
90
|
+
*/
|
|
91
|
+
type InferMiddlewareInput<T> = T extends UnsetMarker ? unknown : T extends z.ZodObject<any> ? z.infer<T> : unknown;
|
|
87
92
|
/** Base config shape for function builders */
|
|
88
93
|
type FunctionBuilderConfig = {
|
|
89
94
|
/** Base function builder (query, mutation, or action from Convex) */
|
|
@@ -176,15 +181,19 @@ declare class ProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends Uns
|
|
|
176
181
|
protected _meta(value: TMeta): ProcedureBuilderDef<TMeta>;
|
|
177
182
|
/** Merge all input schemas into one */
|
|
178
183
|
protected _getMergedInput(): Record<string, any> | undefined;
|
|
179
|
-
protected _createFunction(handler: any, baseFunction: any, customFn: typeof zCustomQuery | typeof zCustomMutation | typeof zCustomAction, fnType: 'query' | 'mutation' | 'action'):
|
|
184
|
+
protected _createFunction(handler: any, baseFunction: any, customFn: typeof zCustomQuery | typeof zCustomMutation | typeof zCustomAction, fnType: 'query' | 'mutation' | 'action'): convex_server30.RegisteredMutation<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredQuery<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredAction<convex_server30.FunctionVisibility, Record<string, unknown>, unknown>;
|
|
180
185
|
}
|
|
181
186
|
/**
|
|
182
187
|
* Query-specific procedure builder
|
|
183
188
|
* Only exposes .query() and .internalQuery() methods
|
|
184
189
|
*/
|
|
185
190
|
declare class QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends UnsetMarker | object = UnsetMarker, TInput extends UnsetMarker | z.ZodObject<any> = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends object = object> extends ProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta> {
|
|
186
|
-
/**
|
|
187
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Add middleware that transforms the context
|
|
193
|
+
* Middleware receives typed input if called after .input(), unknown otherwise
|
|
194
|
+
* $ContextOverridesOut is inferred from next()
|
|
195
|
+
*/
|
|
196
|
+
use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<TBaseCtx, TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): QueryProcedureBuilder<TBaseCtx, TContext, Overwrite<TContextOverrides, $ContextOverridesOut>, TInput, TOutput, TMeta>;
|
|
188
197
|
/** Set procedure metadata (shallow merged when chained) */
|
|
189
198
|
meta(value: TMeta): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
190
199
|
/** Define input schema (chainable - schemas are merged) */
|
|
@@ -212,7 +221,7 @@ declare class QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides extend
|
|
|
212
221
|
query<TResult>(handler: (opts: {
|
|
213
222
|
ctx: Overwrite<TContext, TContextOverrides>;
|
|
214
223
|
input: InferInput<TInput>;
|
|
215
|
-
}) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>):
|
|
224
|
+
}) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): convex_server30.RegisteredMutation<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredQuery<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredAction<convex_server30.FunctionVisibility, Record<string, unknown>, unknown>;
|
|
216
225
|
/** Mark as internal - returns chainable builder using internal function */
|
|
217
226
|
internal(): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
218
227
|
}
|
|
@@ -221,8 +230,12 @@ declare class QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides extend
|
|
|
221
230
|
* Only exposes .mutation() and .internalMutation() methods
|
|
222
231
|
*/
|
|
223
232
|
declare class MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends UnsetMarker | object = UnsetMarker, TInput extends UnsetMarker | z.ZodObject<any> = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends object = object> extends ProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta> {
|
|
224
|
-
/**
|
|
225
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Add middleware that transforms the context
|
|
235
|
+
* Middleware receives typed input if called after .input(), unknown otherwise
|
|
236
|
+
* $ContextOverridesOut is inferred from next()
|
|
237
|
+
*/
|
|
238
|
+
use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<TBaseCtx, TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): MutationProcedureBuilder<TBaseCtx, TContext, Overwrite<TContextOverrides, $ContextOverridesOut>, TInput, TOutput, TMeta>;
|
|
226
239
|
/** Set procedure metadata (shallow merged when chained) */
|
|
227
240
|
meta(value: TMeta): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
228
241
|
/** Define input schema (chainable - schemas are merged) */
|
|
@@ -233,7 +246,7 @@ declare class MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides ext
|
|
|
233
246
|
mutation<TResult>(handler: (opts: {
|
|
234
247
|
ctx: Overwrite<TContext, TContextOverrides>;
|
|
235
248
|
input: InferInput<TInput>;
|
|
236
|
-
}) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>):
|
|
249
|
+
}) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): convex_server30.RegisteredMutation<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredQuery<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredAction<convex_server30.FunctionVisibility, Record<string, unknown>, unknown>;
|
|
237
250
|
/** Mark as internal - returns chainable builder using internal function */
|
|
238
251
|
internal(): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
239
252
|
}
|
|
@@ -243,7 +256,7 @@ declare class MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides ext
|
|
|
243
256
|
*/
|
|
244
257
|
declare class ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends UnsetMarker | object = UnsetMarker, TInput extends UnsetMarker | z.ZodObject<any> = UnsetMarker, TOutput extends UnsetMarker | z.ZodTypeAny = UnsetMarker, TMeta extends object = object> extends ProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta> {
|
|
245
258
|
/** Add middleware that transforms the context - $ContextOverridesOut is inferred from next() */
|
|
246
|
-
use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut
|
|
259
|
+
use<$ContextOverridesOut extends object>(middlewareOrBuilder: MiddlewareFunction<Overwrite<TContext, TContextOverrides>, TMeta, TContextOverrides, $ContextOverridesOut, InferMiddlewareInput<TInput>> | MiddlewareBuilder<TBaseCtx, TMeta, $ContextOverridesOut, InferMiddlewareInput<TInput>>): ActionProcedureBuilder<TBaseCtx, TContext, Overwrite<TContextOverrides, $ContextOverridesOut>, TInput, TOutput, TMeta>;
|
|
247
260
|
/** Set procedure metadata (shallow merged when chained) */
|
|
248
261
|
meta(value: TMeta): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
249
262
|
/** Define input schema (chainable - schemas are merged) */
|
|
@@ -254,7 +267,7 @@ declare class ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides exten
|
|
|
254
267
|
action<TResult>(handler: (opts: {
|
|
255
268
|
ctx: Overwrite<TContext, TContextOverrides>;
|
|
256
269
|
input: InferInput<TInput>;
|
|
257
|
-
}) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>):
|
|
270
|
+
}) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): convex_server30.RegisteredMutation<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredQuery<convex_server30.FunctionVisibility, Record<string, unknown>, unknown> | convex_server30.RegisteredAction<convex_server30.FunctionVisibility, Record<string, unknown>, unknown>;
|
|
258
271
|
/** Mark as internal - returns chainable builder using internal function */
|
|
259
272
|
internal(): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
|
|
260
273
|
}
|
|
@@ -618,4 +631,4 @@ type InferInputsRecursive<T> = T extends FunctionReference<infer _T, 'public'> ?
|
|
|
618
631
|
*/
|
|
619
632
|
type inferApiInputs<TApi> = { [K in keyof TApi]-?: InferInputsRecursive<UnwrapOptional<TApi[K]>> };
|
|
620
633
|
//#endregion
|
|
621
|
-
export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureBuilder, ProcedureMeta, QueryProcedureBuilder, ResolveIfSet, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, createCallerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createServerCaller, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, initCRPC, isCRPCError, matchPathParams };
|
|
634
|
+
export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureBuilder, ProcedureMeta, QueryProcedureBuilder, ResolveIfSet, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, createCallerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createServerCaller, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, initCRPC, isCRPCError, matchPathParams };
|
package/dist/server/index.js
CHANGED
|
@@ -225,14 +225,22 @@ function createProcedure(def, handler, _type) {
|
|
|
225
225
|
const url = new URL(request.url);
|
|
226
226
|
const pathParams = c.req.param() ?? matchPathParams(def.route.path, url.pathname) ?? {};
|
|
227
227
|
let ctx = def.functionConfig.createContext(convexCtx);
|
|
228
|
+
const getRawInput = async () => {
|
|
229
|
+
if ((request.headers.get("content-type") ?? "").includes("application/json")) return request.clone().json();
|
|
230
|
+
return null;
|
|
231
|
+
};
|
|
232
|
+
let currentInput;
|
|
228
233
|
for (const middleware of def.middlewares) {
|
|
229
234
|
const result$1 = await middleware({
|
|
230
235
|
ctx,
|
|
236
|
+
input: currentInput,
|
|
237
|
+
getRawInput,
|
|
231
238
|
next: async (opts) => {
|
|
232
239
|
if (opts?.ctx) ctx = {
|
|
233
240
|
...ctx,
|
|
234
241
|
...opts.ctx
|
|
235
242
|
};
|
|
243
|
+
if (opts?.input !== void 0) currentInput = opts.input;
|
|
236
244
|
return {
|
|
237
245
|
ctx,
|
|
238
246
|
marker: void 0
|
|
@@ -639,21 +647,32 @@ function createMiddlewareFactory() {
|
|
|
639
647
|
return createMiddlewareInner([fn]);
|
|
640
648
|
};
|
|
641
649
|
}
|
|
642
|
-
/** Execute middleware chain recursively */
|
|
643
|
-
async function executeMiddlewares(middlewares, ctx, meta, index = 0) {
|
|
650
|
+
/** Execute middleware chain recursively with input access */
|
|
651
|
+
async function executeMiddlewares(middlewares, ctx, meta, input, getRawInput, index = 0) {
|
|
644
652
|
if (index >= middlewares.length) return {
|
|
645
653
|
marker: void 0,
|
|
646
|
-
ctx
|
|
654
|
+
ctx,
|
|
655
|
+
input
|
|
647
656
|
};
|
|
648
657
|
const middleware = middlewares[index];
|
|
658
|
+
let currentInput = input;
|
|
649
659
|
const next = async (opts) => {
|
|
650
|
-
|
|
660
|
+
const nextCtx = opts?.ctx ?? ctx;
|
|
661
|
+
const nextInput = opts?.input ?? currentInput;
|
|
662
|
+
if (opts?.input !== void 0) currentInput = opts.input;
|
|
663
|
+
return await executeMiddlewares(middlewares, nextCtx, meta, nextInput, getRawInput, index + 1);
|
|
664
|
+
};
|
|
665
|
+
return {
|
|
666
|
+
marker: void 0,
|
|
667
|
+
ctx: (await middleware({
|
|
668
|
+
ctx,
|
|
669
|
+
meta,
|
|
670
|
+
input,
|
|
671
|
+
getRawInput,
|
|
672
|
+
next
|
|
673
|
+
})).ctx ?? ctx,
|
|
674
|
+
input: currentInput
|
|
651
675
|
};
|
|
652
|
-
return middleware({
|
|
653
|
-
ctx,
|
|
654
|
-
meta,
|
|
655
|
-
next
|
|
656
|
-
});
|
|
657
676
|
}
|
|
658
677
|
/**
|
|
659
678
|
* Fluent procedure builder with full type inference
|
|
@@ -711,15 +730,17 @@ var ProcedureBuilder = class {
|
|
|
711
730
|
_createFunction(handler, baseFunction, customFn, fnType) {
|
|
712
731
|
const { middlewares, outputSchema, meta, functionConfig, isInternal } = this._def;
|
|
713
732
|
const mergedInput = this._getMergedInput();
|
|
714
|
-
const fn = customFn(baseFunction, customCtx(async (_ctx) => {
|
|
715
|
-
return (await executeMiddlewares(middlewares, functionConfig.createContext(_ctx), meta)).ctx;
|
|
716
|
-
}))({
|
|
733
|
+
const fn = customFn(baseFunction, customCtx(async (_ctx) => functionConfig.createContext(_ctx)))({
|
|
717
734
|
args: mergedInput ?? {},
|
|
718
735
|
...outputSchema ? { returns: outputSchema } : {},
|
|
719
|
-
handler: async (ctx,
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
736
|
+
handler: async (ctx, rawInput) => {
|
|
737
|
+
const getRawInput = async () => rawInput;
|
|
738
|
+
const result = await executeMiddlewares(middlewares, ctx, meta, rawInput, getRawInput);
|
|
739
|
+
return handler({
|
|
740
|
+
ctx: result.ctx,
|
|
741
|
+
input: result.input ?? rawInput
|
|
742
|
+
});
|
|
743
|
+
}
|
|
723
744
|
});
|
|
724
745
|
fn._crpcMeta = {
|
|
725
746
|
type: fnType,
|
|
@@ -734,7 +755,11 @@ var ProcedureBuilder = class {
|
|
|
734
755
|
* Only exposes .query() and .internalQuery() methods
|
|
735
756
|
*/
|
|
736
757
|
var QueryProcedureBuilder = class QueryProcedureBuilder extends ProcedureBuilder {
|
|
737
|
-
/**
|
|
758
|
+
/**
|
|
759
|
+
* Add middleware that transforms the context
|
|
760
|
+
* Middleware receives typed input if called after .input(), unknown otherwise
|
|
761
|
+
* $ContextOverridesOut is inferred from next()
|
|
762
|
+
*/
|
|
738
763
|
use(middlewareOrBuilder) {
|
|
739
764
|
return new QueryProcedureBuilder(this._use(middlewareOrBuilder));
|
|
740
765
|
}
|
|
@@ -802,7 +827,11 @@ var QueryProcedureBuilder = class QueryProcedureBuilder extends ProcedureBuilder
|
|
|
802
827
|
* Only exposes .mutation() and .internalMutation() methods
|
|
803
828
|
*/
|
|
804
829
|
var MutationProcedureBuilder = class MutationProcedureBuilder extends ProcedureBuilder {
|
|
805
|
-
/**
|
|
830
|
+
/**
|
|
831
|
+
* Add middleware that transforms the context
|
|
832
|
+
* Middleware receives typed input if called after .input(), unknown otherwise
|
|
833
|
+
* $ContextOverridesOut is inferred from next()
|
|
834
|
+
*/
|
|
806
835
|
use(middlewareOrBuilder) {
|
|
807
836
|
return new MutationProcedureBuilder(this._use(middlewareOrBuilder));
|
|
808
837
|
}
|
|
@@ -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-DAM81UvD.js";
|
|
2
2
|
import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
|
|
3
3
|
import { DefaultError, QueryFilters, SkipToken, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
import { Watch, WatchQueryOptions } from "convex/react";
|