better-convex 0.5.2 → 0.5.4

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.
@@ -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 convex_server48 from "convex/server";
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: convex_server48.RegisteredMutation<"internal", {
51
+ beforeCreate: convex_server24.RegisteredMutation<"internal", {
52
52
  data: any;
53
53
  model: string;
54
54
  }, Promise<any>>;
55
- beforeDelete: convex_server48.RegisteredMutation<"internal", {
55
+ beforeDelete: convex_server24.RegisteredMutation<"internal", {
56
56
  model: string;
57
57
  doc: any;
58
58
  }, Promise<any>>;
59
- beforeUpdate: convex_server48.RegisteredMutation<"internal", {
59
+ beforeUpdate: convex_server24.RegisteredMutation<"internal", {
60
60
  update: any;
61
61
  model: string;
62
62
  doc: any;
63
63
  }, Promise<any>>;
64
- onCreate: convex_server48.RegisteredMutation<"internal", {
64
+ onCreate: convex_server24.RegisteredMutation<"internal", {
65
65
  model: string;
66
66
  doc: any;
67
67
  }, Promise<void>>;
68
- onDelete: convex_server48.RegisteredMutation<"internal", {
68
+ onDelete: convex_server24.RegisteredMutation<"internal", {
69
69
  model: string;
70
70
  doc: any;
71
71
  }, Promise<void>>;
72
- onUpdate: convex_server48.RegisteredMutation<"internal", {
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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<"in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "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>;
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", "value" | "operator" | "field" | "connector">;
176
+ }, "required", "operator" | "value" | "field" | "connector">;
177
177
  declare const adapterArgsValidator: convex_values0.VObject<{
178
178
  limit?: number | undefined;
179
179
  where?: {
180
- operator?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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<"in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "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>;
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", "value" | "operator" | "field" | "connector">, "optional">;
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<convex_server48.GenericDocument | null>;
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<convex_server48.PaginationResult<convex_server48.GenericDocument>>;
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: convex_server48.Cursor;
283
- splitCursor?: convex_server48.Cursor | null;
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<convex_server48.GenericDocument | undefined>;
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: convex_server48.Cursor;
309
- splitCursor?: convex_server48.Cursor | null;
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: convex_server48.RegisteredMutation<"internal", {
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: convex_server48.RegisteredMutation<"internal", {
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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: convex_server48.Cursor;
361
- splitCursor?: convex_server48.Cursor | null;
360
+ continueCursor: convex_server24.Cursor;
361
+ splitCursor?: convex_server24.Cursor | null;
362
362
  pageStatus?: "SplitRecommended" | "SplitRequired" | null;
363
363
  }>>;
364
- deleteOne: convex_server48.RegisteredMutation<"internal", {
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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<convex_server48.GenericDocument | undefined>>;
380
- findMany: convex_server48.RegisteredQuery<"internal", {
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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<convex_server48.PaginationResult<convex_server48.GenericDocument>>>;
404
- findOne: convex_server48.RegisteredQuery<"internal", {
403
+ }, Promise<convex_server24.PaginationResult<convex_server24.GenericDocument>>>;
404
+ findOne: convex_server24.RegisteredQuery<"internal", {
405
405
  join?: any;
406
406
  where?: {
407
- operator?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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<convex_server48.GenericDocument | null>>;
415
- updateMany: convex_server48.RegisteredMutation<"internal", {
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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: convex_server48.Cursor;
449
- splitCursor?: convex_server48.Cursor | null;
448
+ continueCursor: convex_server24.Cursor;
449
+ splitCursor?: convex_server24.Cursor | null;
450
450
  pageStatus?: "SplitRecommended" | "SplitRequired" | null;
451
451
  }>>;
452
- updateOne: convex_server48.RegisteredMutation<"internal", {
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?: "in" | "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
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: convex_server48.RegisteredAction<"internal", {}, Promise<any>>;
475
- rotateKeys: convex_server48.RegisteredAction<"internal", {}, Promise<any>>;
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
@@ -629,7 +629,7 @@ const httpAdapter = (ctx, { authFunctions, debugLogs, triggers }) => {
629
629
  });
630
630
  },
631
631
  createSchema: async ({ file, tables }) => {
632
- const { createSchema } = await import("../create-schema-DzQEFNJW.js");
632
+ const { createSchema } = await import("../create-schema-Dc8IZ4SX.js");
633
633
  return createSchema({
634
634
  file,
635
635
  tables
@@ -765,7 +765,7 @@ const dbAdapter = (ctx, createAuthOptions, { authFunctions, debugLogs, schema, t
765
765
  }, schema, betterAuthSchema);
766
766
  },
767
767
  createSchema: async ({ file, tables }) => {
768
- const { createSchema } = await import("../create-schema-DzQEFNJW.js");
768
+ const { createSchema } = await import("../create-schema-Dc8IZ4SX.js");
769
769
  return createSchema({
770
770
  file,
771
771
  tables
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { _ as defaultIsUnauthorized, d as useAuthStore, f as useAuthValue, g as CRPCClientError, r as FetchAccessTokenContext, s as decodeJwtExp, t as AuthProvider } from "../auth-store-BMSJFMtR.js";
2
+ import { _ as CRPCClientError, d as useAuthStore, f as useAuthValue, r as FetchAccessTokenContext, s as decodeJwtExp, t as AuthProvider, v as defaultIsUnauthorized } from "../auth-store-BzSR1-8h.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import { ConvexProviderWithAuth, useConvexAuth } from "convex/react";
5
5
  import { useCallback, useEffect, useRef } from "react";
@@ -1,4 +1,4 @@
1
- import "../http-types-DAM81UvD.js";
1
+ import "../http-types-DqMo3PY9.js";
2
2
  import { CallerMeta, ConvexContext, LazyCaller } from "../server/index.js";
3
3
  import { GetTokenOptions } from "@convex-dev/better-auth/utils";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { n as defaultIsUnauthorized } from "../error-CNMP5iLQ.js";
2
- import { t as createCallerFactory } from "../caller-factory-DxmuY355.js";
2
+ import { t as createCallerFactory } from "../caller-factory-CuyVsPAc.js";
3
3
  import { getToken } from "@convex-dev/better-auth/utils";
4
4
 
5
5
  //#region src/auth-nextjs/index.ts
@@ -71,6 +71,17 @@ const { AuthProvider, useAuthStore, useAuthState, useAuthValue } = createAtomSto
71
71
  name: "auth",
72
72
  suppressWarnings: true
73
73
  });
74
+ /**
75
+ * Safe wrapper around useConvexAuth that doesn't throw when used outside auth provider.
76
+ * Returns { isAuthenticated: false, isLoading: false } when no auth provider.
77
+ */
78
+ function useSafeConvexAuth() {
79
+ if (!useAuthStore().store) return {
80
+ isAuthenticated: false,
81
+ isLoading: false
82
+ };
83
+ return useConvexAuth();
84
+ }
74
85
  const useAuth = () => {
75
86
  const authStore = useAuthStore();
76
87
  if (!authStore.store) return {
@@ -102,7 +113,7 @@ const useIsAuth = () => {
102
113
  };
103
114
  const useAuthGuard = () => {
104
115
  const $ = c(3);
105
- const { isAuthenticated } = useConvexAuth();
116
+ const { isAuthenticated } = useSafeConvexAuth();
106
117
  const onMutationUnauthorized = useAuthValue("onMutationUnauthorized");
107
118
  let t0;
108
119
  if ($[0] !== isAuthenticated || $[1] !== onMutationUnauthorized) {
@@ -142,4 +153,4 @@ function Unauthenticated(t0) {
142
153
  }
143
154
 
144
155
  //#endregion
145
- export { defaultIsUnauthorized as _, MaybeUnauthenticated as a, useAuth as c, useAuthStore as d, useAuthValue as f, CRPCClientError as g, useMaybeAuth as h, MaybeAuthenticated as i, useAuthGuard as l, useIsAuth as m, Authenticated as n, Unauthenticated as o, useFetchAccessToken as p, FetchAccessTokenContext as r, decodeJwtExp as s, AuthProvider as t, useAuthState as u, isCRPCClientError as v };
156
+ export { CRPCClientError as _, MaybeUnauthenticated as a, useAuth as c, useAuthStore as d, useAuthValue as f, useSafeConvexAuth as g, useMaybeAuth as h, MaybeAuthenticated as i, useAuthGuard as l, useIsAuth as m, Authenticated as n, Unauthenticated as o, useFetchAccessToken as p, FetchAccessTokenContext as r, decodeJwtExp as s, AuthProvider as t, useAuthState as u, defaultIsUnauthorized as v, isCRPCClientError as y };
@@ -1,20 +1,7 @@
1
+ import { r as getFunctionType, t as getFuncRef$1 } from "./meta-utils-BR_tOx_A.js";
1
2
  import { fetchAction, fetchMutation, fetchQuery } from "convex/nextjs";
2
3
 
3
4
  //#region src/server/caller.ts
4
- function getFuncRef$1(api, path) {
5
- let current = api;
6
- for (const key of path) if (current && typeof current === "object") current = current[key];
7
- else throw new Error(`Invalid caller path: ${path.join(".")}`);
8
- return current;
9
- }
10
- function getFunctionType(path, meta) {
11
- if (path.length >= 2) {
12
- const [namespace, fnName] = path;
13
- const fnType = meta[namespace]?.[fnName]?.type;
14
- if (fnType === "query" || fnType === "mutation" || fnType === "action") return fnType;
15
- }
16
- return "query";
17
- }
18
5
  function createRecursiveProxy(api, path, createOpts) {
19
6
  return new Proxy(() => {}, {
20
7
  get(_target, prop) {
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_codegen = require('./codegen-CdL9lB4u.cjs');
2
+ const require_codegen = require('./codegen-ry3wEe7L.cjs');
3
3
  let node_module = require("node:module");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_codegen.__toESM(node_path);
@@ -32,9 +32,30 @@ let node_fs = require("node:fs");
32
32
  node_fs = __toESM(node_fs);
33
33
  let jiti = require("jiti");
34
34
 
35
+ //#region src/shared/meta-utils.ts
36
+ /** Files to exclude from meta generation */
37
+ const EXCLUDED_FILES = new Set([
38
+ "schema.ts",
39
+ "convex.config.ts",
40
+ "auth.config.ts"
41
+ ]);
42
+ /**
43
+ * Check if a file path should be included in meta generation.
44
+ * Filters out private files/directories (prefixed with _) and config files.
45
+ */
46
+ function isValidConvexFile(file) {
47
+ if (file.startsWith("_") || file.includes("/_")) return false;
48
+ const basename = file.split("/").pop() ?? "";
49
+ if (EXCLUDED_FILES.has(basename)) return false;
50
+ return true;
51
+ }
52
+
53
+ //#endregion
35
54
  //#region src/cli/codegen.ts
36
55
  /** Valid JS identifier pattern for object keys */
37
56
  const VALID_IDENTIFIER_RE = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
57
+ /** Pattern to strip .ts extension */
58
+ const TS_EXTENSION_RE = /\.ts$/;
38
59
  function getConvexConfig(outputDir) {
39
60
  const convexConfigPath = node_path.default.join(process.cwd(), "convex.json");
40
61
  const functionsDir = (node_fs.default.existsSync(convexConfigPath) ? JSON.parse(node_fs.default.readFileSync(convexConfigPath, "utf-8")) : {}).functions || "convex";
@@ -105,14 +126,10 @@ async function generateMeta(outputDir, options) {
105
126
  const meta = {};
106
127
  const allHttpRoutes = {};
107
128
  let totalFunctions = 0;
108
- const files = node_fs.default.readdirSync(functionsDir).filter((file) => file.endsWith(".ts") && !file.startsWith("_") && ![
109
- "schema.ts",
110
- "convex.config.ts",
111
- "auth.config.ts"
112
- ].includes(file));
129
+ const files = (0, node_fs.globSync)("**/*.ts", { cwd: functionsDir }).filter((file) => file.endsWith(".ts") && isValidConvexFile(file));
113
130
  for (const file of files) {
114
131
  const filePath = node_path.default.join(functionsDir, file);
115
- const moduleName = file.replace(".ts", "");
132
+ const moduleName = file.replace(TS_EXTENSION_RE, "");
116
133
  try {
117
134
  const { meta: moduleMeta, httpRoutes } = await parseModuleRuntime(filePath, jiti$1);
118
135
  if (moduleMeta) {
@@ -127,8 +144,9 @@ async function generateMeta(outputDir, options) {
127
144
  if (debug || file === "http.ts") console.error(` ⚠ Failed to parse ${file}:`, error);
128
145
  }
129
146
  }
147
+ const formatKey = (key) => VALID_IDENTIFIER_RE.test(key) ? key : `'${key}'`;
130
148
  const metaEntries = Object.entries(meta).map(([module$1, fns]) => {
131
- return ` ${module$1}: {\n${Object.entries(fns).map(([fn, fnMeta]) => {
149
+ const fnEntries = Object.entries(fns).map(([fn, fnMeta]) => {
132
150
  const metaProps = [];
133
151
  for (const [key, value] of Object.entries(fnMeta).sort()) {
134
152
  if (value === void 0) continue;
@@ -137,7 +155,8 @@ async function generateMeta(outputDir, options) {
137
155
  else if (typeof value === "number") metaProps.push(`${key}: ${value}`);
138
156
  }
139
157
  return ` ${fn}: ${`{ ${metaProps.join(", ")} }`}`;
140
- }).join(",\n")},\n }`;
158
+ }).join(",\n");
159
+ return ` ${formatKey(module$1)}: {\n${fnEntries},\n }`;
141
160
  }).join(",\n");
142
161
  const metaContent = metaEntries ? `\n${metaEntries},\n` : "";
143
162
  const routesByPath = /* @__PURE__ */ new Map();
@@ -155,7 +174,6 @@ async function generateMeta(outputDir, options) {
155
174
  const best = entries.reduce((a, b) => a.key.length >= b.key.length ? a : b);
156
175
  dedupedRoutes[best.key] = best.route;
157
176
  }
158
- const formatKey = (key) => VALID_IDENTIFIER_RE.test(key) ? key : `'${key}'`;
159
177
  const httpEntries = Object.entries(dedupedRoutes).sort(([a], [b]) => a.localeCompare(b)).map(([name, route]) => ` ${formatKey(name)}: { path: '${route.path}', method: '${route.method}' }`).join(",\n");
160
178
  const httpContent = httpEntries ? `\n${httpEntries},\n ` : "";
161
179
  const output = `// biome-ignore-all format: generated
@@ -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-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-V1NljSG9.js";
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-DqMo3PY9.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-Cq1r6gzE.js";
3
3
  import { FunctionArgs, FunctionReference } from "convex/server";
4
4
 
5
5
  //#region src/crpc/error.d.ts
@@ -1,5 +1,5 @@
1
1
  import { a as isCRPCErrorCode, i as isCRPCError, n as defaultIsUnauthorized, r as isCRPCClientError, t as CRPCClientError } from "../error-CNMP5iLQ.js";
2
- import { n as convexInfiniteQueryOptions, r as convexQuery, t as convexAction } from "../query-options-sK2n1Ioe.js";
2
+ import { n as convexInfiniteQueryOptions, r as convexQuery, t as convexAction } from "../query-options-Cwz_w7q-.js";
3
3
 
4
4
  //#region src/crpc/http-types.ts
5
5
  /** HTTP client error */
@@ -0,0 +1,41 @@
1
+ //#region src/shared/meta-utils.ts
2
+ /**
3
+ * Get a function reference from the API object by traversing the path.
4
+ */
5
+ function getFuncRef(api, path) {
6
+ let current = api;
7
+ for (const key of path) if (current && typeof current === "object") current = current[key];
8
+ else throw new Error(`Invalid path: ${path.join(".")}`);
9
+ return current;
10
+ }
11
+ /**
12
+ * Get function type from meta using path.
13
+ * Supports nested paths like ['items', 'queries', 'list'] → namespace='items/queries', fn='list'
14
+ *
15
+ * @param path - Path segments like ['todos', 'create'] or ['items', 'queries', 'list']
16
+ * @param meta - The meta object from codegen
17
+ * @returns Function type or 'query' as default
18
+ */
19
+ function getFunctionType(path, meta) {
20
+ if (path.length < 2) return "query";
21
+ const fnName = path.at(-1);
22
+ const fnType = meta[path.slice(0, -1).join("/")]?.[fnName]?.type;
23
+ if (fnType === "query" || fnType === "mutation" || fnType === "action") return fnType;
24
+ return "query";
25
+ }
26
+ /**
27
+ * Get function metadata from meta using path.
28
+ * Supports nested paths like ['items', 'queries', 'list'] → namespace='items/queries', fn='list'
29
+ *
30
+ * @param path - Path segments like ['todos', 'create'] or ['items', 'queries', 'list']
31
+ * @param meta - The meta object from codegen
32
+ * @returns Function metadata or undefined
33
+ */
34
+ function getFunctionMeta(path, meta) {
35
+ if (path.length < 2) return;
36
+ const fnName = path.at(-1);
37
+ return meta[path.slice(0, -1).join("/")]?.[fnName];
38
+ }
39
+
40
+ //#endregion
41
+ export { getFunctionMeta as n, getFunctionType as r, getFuncRef as t };
@@ -126,6 +126,14 @@ declare const AuthProvider: react0.FC<jotai_x0.ProviderProps<{
126
126
  equalityFn?: ((prev: S, next: S) => boolean) | undefined;
127
127
  } & jotai_x0.UseAtomOptions) | undefined, deps?: unknown[]) => S;
128
128
  type AuthStore = ReturnType<typeof useAuthStore>;
129
+ /**
130
+ * Safe wrapper around useConvexAuth that doesn't throw when used outside auth provider.
131
+ * Returns { isAuthenticated: false, isLoading: false } when no auth provider.
132
+ */
133
+ declare function useSafeConvexAuth(): {
134
+ isAuthenticated: boolean;
135
+ isLoading: boolean;
136
+ };
129
137
  declare const useAuth: () => {
130
138
  hasSession: boolean;
131
139
  isAuthenticated: boolean;
@@ -1224,4 +1232,4 @@ declare function useUploadMutationOptions<TGenerateUrlMutation extends FunctionR
1224
1232
  */
1225
1233
  declare function createVanillaCRPCProxy<TApi extends Record<string, unknown>>(api: TApi, meta: CallerMeta, convexClient: ConvexReactClient$1): VanillaCRPCClient<TApi>;
1226
1234
  //#endregion
1227
- 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, VanillaHttpCRPCClient, VanillaHttpCRPCClientFromRouter, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
1235
+ 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, VanillaHttpCRPCClient, VanillaHttpCRPCClientFromRouter, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useSafeConvexAuth as useConvexAuth, useSafeConvexAuth, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- import { a as MaybeUnauthenticated, c as useAuth, d as useAuthStore, f as useAuthValue, g as CRPCClientError, h as useMaybeAuth, i as MaybeAuthenticated, l as useAuthGuard, m as useIsAuth, n as Authenticated, o as Unauthenticated, p as useFetchAccessToken, r as FetchAccessTokenContext, s as decodeJwtExp, t as AuthProvider, u as useAuthState, v as isCRPCClientError } from "../auth-store-BMSJFMtR.js";
2
+ import { _ as CRPCClientError, a as MaybeUnauthenticated, c as useAuth, d as useAuthStore, f as useAuthValue, g as useSafeConvexAuth, h as useMaybeAuth, i as MaybeAuthenticated, l as useAuthGuard, m as useIsAuth, n as Authenticated, o as Unauthenticated, p as useFetchAccessToken, r as FetchAccessTokenContext, s as decodeJwtExp, t as AuthProvider, u as useAuthState, y as isCRPCClientError } from "../auth-store-BzSR1-8h.js";
3
3
  import { c } from "react/compiler-runtime";
4
- import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, useAction, useConvex, useConvexAuth, useMutation } from "convex/react";
4
+ import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, useAction, useConvex, useMutation } from "convex/react";
5
5
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { hashKey, notifyManager, skipToken, useQueries, useQueryClient } from "@tanstack/react-query";
@@ -401,6 +401,46 @@ function convexInfiniteQueryOptions(funcRef, args, opts = {}, meta) {
401
401
  /** Symbol key for attaching FunctionReference to options (non-serializable) */
402
402
  const FUNC_REF_SYMBOL = Symbol.for("convex.funcRef");
403
403
 
404
+ //#endregion
405
+ //#region src/shared/meta-utils.ts
406
+ /**
407
+ * Get a function reference from the API object by traversing the path.
408
+ */
409
+ function getFuncRef(api, path) {
410
+ let current = api;
411
+ for (const key of path) if (current && typeof current === "object") current = current[key];
412
+ else throw new Error(`Invalid path: ${path.join(".")}`);
413
+ return current;
414
+ }
415
+ /**
416
+ * Get function type from meta using path.
417
+ * Supports nested paths like ['items', 'queries', 'list'] → namespace='items/queries', fn='list'
418
+ *
419
+ * @param path - Path segments like ['todos', 'create'] or ['items', 'queries', 'list']
420
+ * @param meta - The meta object from codegen
421
+ * @returns Function type or 'query' as default
422
+ */
423
+ function getFunctionType(path, meta) {
424
+ if (path.length < 2) return "query";
425
+ const fnName = path.at(-1);
426
+ const fnType = meta[path.slice(0, -1).join("/")]?.[fnName]?.type;
427
+ if (fnType === "query" || fnType === "mutation" || fnType === "action") return fnType;
428
+ return "query";
429
+ }
430
+ /**
431
+ * Get function metadata from meta using path.
432
+ * Supports nested paths like ['items', 'queries', 'list'] → namespace='items/queries', fn='list'
433
+ *
434
+ * @param path - Path segments like ['todos', 'create'] or ['items', 'queries', 'list']
435
+ * @param meta - The meta object from codegen
436
+ * @returns Function metadata or undefined
437
+ */
438
+ function getFunctionMeta(path, meta) {
439
+ if (path.length < 2) return;
440
+ const fnName = path.at(-1);
441
+ return meta[path.slice(0, -1).join("/")]?.[fnName];
442
+ }
443
+
404
444
  //#endregion
405
445
  //#region src/internal/auth.ts
406
446
  /** Get auth type from meta for a function */
@@ -411,7 +451,7 @@ function getAuthType(meta, funcName) {
411
451
  /** Hook to compute auth-based skip logic for queries */
412
452
  function useAuthSkip(funcRef, opts) {
413
453
  const $ = c(8);
414
- const { isAuthenticated, isLoading: isAuthLoading } = useConvexAuth();
454
+ const { isAuthenticated, isLoading: isAuthLoading } = useSafeConvexAuth();
415
455
  const meta = useMeta();
416
456
  let t0;
417
457
  if ($[0] !== funcRef || $[1] !== meta) {
@@ -882,29 +922,9 @@ function useUploadMutationOptions(generateUrlMutation, options) {
882
922
  * const { data } = useQuery(opts);
883
923
  * ```
884
924
  */
885
- /**
886
- * Get a function reference from the API object by traversing the path.
887
- * Note: Convex's api object is a Proxy, so we use direct property access
888
- * instead of `in` operator which may not work with all proxy implementations.
889
- */
890
- function getFuncRef$1(api, path) {
891
- let current = api;
892
- for (const key of path) if (current && typeof current === "object") current = current[key];
893
- else throw new Error(`Invalid CRPC path: ${path.join(".")}`);
894
- return current;
895
- }
896
- /** Get function type from meta using path */
897
- function getFunctionType$1(path, meta) {
898
- if (path.length >= 2) {
899
- const [namespace, fnName] = path;
900
- const fnType = meta[namespace]?.[fnName]?.type;
901
- if (fnType === "query" || fnType === "mutation" || fnType === "action") return fnType;
902
- }
903
- return "query";
904
- }
905
925
  /** Get query key prefix based on function type */
906
926
  function getQueryKeyPrefix(path, meta) {
907
- if (getFunctionType$1(path, meta) === "action") return "convexAction";
927
+ if (getFunctionType(path, meta) === "action") return "convexAction";
908
928
  return "convexQuery";
909
929
  }
910
930
  /**
@@ -915,19 +935,19 @@ function createRecursiveProxy(api, path, meta) {
915
935
  if (typeof prop === "symbol") return;
916
936
  if (prop === "then") return;
917
937
  if (prop === "queryOptions") return (args = {}, opts) => {
918
- const funcRef = getFuncRef$1(api, path);
919
- if (getFunctionType$1(path, meta) === "action") return useConvexActionQueryOptions(funcRef, args, opts);
938
+ const funcRef = getFuncRef(api, path);
939
+ if (getFunctionType(path, meta) === "action") return useConvexActionQueryOptions(funcRef, args, opts);
920
940
  return useConvexQueryOptions(funcRef, args, opts);
921
941
  };
922
942
  if (prop === "staticQueryOptions") return (args = {}, opts) => {
923
- const funcRef = getFuncRef$1(api, path);
924
- const fnType = getFunctionType$1(path, meta);
943
+ const funcRef = getFuncRef(api, path);
944
+ const fnType = getFunctionType(path, meta);
925
945
  const finalArgs = args === skipToken ? "skip" : args;
926
946
  if (fnType === "action") return convexAction(funcRef, finalArgs, meta, opts);
927
947
  return convexQuery(funcRef, finalArgs, meta, opts);
928
948
  };
929
949
  if (prop === "queryKey") return (args = {}) => {
930
- const funcName = getFunctionName(getFuncRef$1(api, path));
950
+ const funcName = getFunctionName(getFuncRef(api, path));
931
951
  return [
932
952
  getQueryKeyPrefix(path, meta),
933
953
  funcName,
@@ -935,7 +955,7 @@ function createRecursiveProxy(api, path, meta) {
935
955
  ];
936
956
  };
937
957
  if (prop === "queryFilter") return (args, filters) => {
938
- const funcName = getFunctionName(getFuncRef$1(api, path));
958
+ const funcName = getFunctionName(getFuncRef(api, path));
939
959
  const prefix = getQueryKeyPrefix(path, meta);
940
960
  return {
941
961
  ...filters,
@@ -947,7 +967,7 @@ function createRecursiveProxy(api, path, meta) {
947
967
  };
948
968
  };
949
969
  if (prop === "infiniteQueryOptions") return (args = {}, opts = {}) => {
950
- const funcRef = getFuncRef$1(api, path);
970
+ const funcRef = getFuncRef(api, path);
951
971
  const options = useConvexInfiniteQueryOptions(funcRef, args, opts);
952
972
  Object.defineProperty(options, FUNC_REF_SYMBOL, {
953
973
  value: funcRef,
@@ -959,20 +979,17 @@ function createRecursiveProxy(api, path, meta) {
959
979
  if (prop === "infiniteQueryKey") return (args) => {
960
980
  return [
961
981
  "convexQuery",
962
- getFunctionName(getFuncRef$1(api, path)),
982
+ getFunctionName(getFuncRef(api, path)),
963
983
  args ?? {}
964
984
  ];
965
985
  };
966
- if (prop === "meta" && path.length >= 2) {
967
- const [namespace, fnName] = path;
968
- return meta[namespace]?.[fnName];
969
- }
986
+ if (prop === "meta" && path.length >= 2) return getFunctionMeta(path, meta);
970
987
  if (prop === "mutationKey") return () => {
971
- return ["convexMutation", getFunctionName(getFuncRef$1(api, path))];
988
+ return ["convexMutation", getFunctionName(getFuncRef(api, path))];
972
989
  };
973
990
  if (prop === "mutationOptions") return (opts) => {
974
- const funcRef = getFuncRef$1(api, path);
975
- if (getFunctionType$1(path, meta) === "action") return useConvexActionOptions(funcRef, opts);
991
+ const funcRef = getFuncRef(api, path);
992
+ if (getFunctionType(path, meta) === "action") return useConvexActionOptions(funcRef, opts);
976
993
  return useConvexMutationOptions(funcRef, opts);
977
994
  };
978
995
  return createRecursiveProxy(api, [...path, prop], meta);
@@ -1008,24 +1025,6 @@ function createCRPCOptionsProxy(api, meta) {
1008
1025
  //#endregion
1009
1026
  //#region src/react/vanilla-client.ts
1010
1027
  /**
1011
- * Get a function reference from the API object by traversing the path.
1012
- */
1013
- function getFuncRef(api, path) {
1014
- let current = api;
1015
- for (const key of path) if (current && typeof current === "object") current = current[key];
1016
- else throw new Error(`Invalid CRPC path: ${path.join(".")}`);
1017
- return current;
1018
- }
1019
- /** Get function type from meta using path */
1020
- function getFunctionType(path, meta) {
1021
- if (path.length >= 2) {
1022
- const [namespace, fnName] = path;
1023
- const fnType = meta[namespace]?.[fnName]?.type;
1024
- if (fnType === "query" || fnType === "mutation" || fnType === "action") return fnType;
1025
- }
1026
- return "query";
1027
- }
1028
- /**
1029
1028
  * Create a recursive proxy for vanilla (direct) calls.
1030
1029
  */
1031
1030
  function createRecursiveVanillaProxy(api, path, meta, convexClient) {
@@ -2138,7 +2137,7 @@ const useStaleCursorRecovery = (t0) => {
2138
2137
  */
2139
2138
  const useInfiniteQueryInternal = (query, args, options) => {
2140
2139
  const { limit, enabled, placeholderData, ...queryOptions } = options;
2141
- const { isLoading: isAuthLoading } = useConvexAuth();
2140
+ const { isLoading: isAuthLoading } = useSafeConvexAuth();
2142
2141
  const meta = useMeta();
2143
2142
  const queryClient = useQueryClient();
2144
2143
  const prefetchedFirstPage = useMemo(() => {
@@ -2430,7 +2429,7 @@ function useInfiniteQuery(infiniteOptions) {
2430
2429
  const $ = c(35);
2431
2430
  const query = infiniteOptions[FUNC_REF_SYMBOL];
2432
2431
  const onQueryUnauthorized = useAuthValue("onQueryUnauthorized");
2433
- const { isLoading: isAuthLoading, isAuthenticated } = useConvexAuth();
2432
+ const { isLoading: isAuthLoading, isAuthenticated } = useSafeConvexAuth();
2434
2433
  let factoryEnabled;
2435
2434
  let meta;
2436
2435
  let queryOptions;
@@ -2578,4 +2577,4 @@ function _temp2(prev_0) {
2578
2577
  }
2579
2578
 
2580
2579
  //#endregion
2581
- export { AuthProvider, Authenticated, ConvexProvider, ConvexQueryClient, ConvexReactClient, FetchAccessTokenContext, MaybeAuthenticated, MaybeUnauthenticated, Unauthenticated, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
2580
+ export { AuthProvider, Authenticated, ConvexProvider, ConvexQueryClient, ConvexReactClient, FetchAccessTokenContext, MaybeAuthenticated, MaybeUnauthenticated, Unauthenticated, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useSafeConvexAuth as useConvexAuth, useSafeConvexAuth, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
@@ -1,5 +1,5 @@
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-V1NljSG9.js";
1
+ import { E as HttpProcedure, W as UnsetMarker, f as DistributiveOmit, g as HttpRouterRecord, m as CRPCHttpRouter, p as Simplify } from "../http-types-DqMo3PY9.js";
2
+ import { S as Meta, n as CRPCClient } from "../types-Cq1r6gzE.js";
3
3
  import { DefaultError, QueryFilters, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
4
4
  import { z } from "zod";
5
5
 
package/dist/rsc/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { n as convexInfiniteQueryOptions, r as convexQuery } from "../query-options-sK2n1Ioe.js";
1
+ import { n as getFunctionMeta, t as getFuncRef } from "../meta-utils-BR_tOx_A.js";
2
+ import { n as convexInfiniteQueryOptions, r as convexQuery } from "../query-options-Cwz_w7q-.js";
2
3
  import { getFunctionName } from "convex/server";
3
4
  import { convexToJson } from "convex/values";
4
5
  import { fetchAction, fetchQuery } from "convex/nextjs";
@@ -66,12 +67,6 @@ function buildUrl(convexSiteUrl, pathTemplate, args) {
66
67
  * Provides a proxy that works in React Server Components.
67
68
  * Query execution is delegated to getServerQueryClientOptions.
68
69
  */
69
- function getFuncRef(api, path) {
70
- let current = api;
71
- for (const key of path) if (current && typeof current === "object") current = current[key];
72
- else throw new Error(`Invalid CRPC path: ${path.join(".")}`);
73
- return current;
74
- }
75
70
  function createRecursiveProxy(api, path, meta) {
76
71
  return new Proxy(() => {}, { get(_target, prop) {
77
72
  if (typeof prop === "symbol") return;
@@ -95,10 +90,7 @@ function createRecursiveProxy(api, path, meta) {
95
90
  args ?? {}
96
91
  ];
97
92
  };
98
- if (prop === "meta" && path.length >= 2) {
99
- const [namespace, fnName] = path;
100
- return meta[namespace]?.[fnName];
101
- }
93
+ if (prop === "meta" && path.length >= 2) return getFunctionMeta(path, meta);
102
94
  return createRecursiveProxy(api, [...path, prop], meta);
103
95
  } });
104
96
  }
@@ -1,5 +1,5 @@
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_server0 from "convex/server";
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-DqMo3PY9.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";
@@ -181,7 +181,7 @@ declare class ProcedureBuilder<TBaseCtx, TContext, TContextOverrides extends Uns
181
181
  protected _meta(value: TMeta): ProcedureBuilderDef<TMeta>;
182
182
  /** Merge all input schemas into one */
183
183
  protected _getMergedInput(): Record<string, any> | undefined;
184
- protected _createFunction(handler: any, baseFunction: any, customFn: typeof zCustomQuery | typeof zCustomMutation | typeof zCustomAction, fnType: 'query' | 'mutation' | 'action'): convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, Record<string, unknown>, unknown>;
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>;
185
185
  }
186
186
  /**
187
187
  * Query-specific procedure builder
@@ -223,7 +223,7 @@ declare class QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides extend
223
223
  query<TResult>(handler: (opts: {
224
224
  ctx: Overwrite<TContext, TContextOverrides>;
225
225
  input: InferInput<TInput>;
226
- }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, Record<string, unknown>, unknown>;
226
+ }) => 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>;
227
227
  /** Mark as internal - returns chainable builder using internal function */
228
228
  internal(): QueryProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
229
229
  }
@@ -250,7 +250,7 @@ declare class MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides ext
250
250
  mutation<TResult>(handler: (opts: {
251
251
  ctx: Overwrite<TContext, TContextOverrides>;
252
252
  input: InferInput<TInput>;
253
- }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, Record<string, unknown>, unknown>;
253
+ }) => 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>;
254
254
  /** Mark as internal - returns chainable builder using internal function */
255
255
  internal(): MutationProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
256
256
  }
@@ -273,7 +273,7 @@ declare class ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides exten
273
273
  action<TResult>(handler: (opts: {
274
274
  ctx: Overwrite<TContext, TContextOverrides>;
275
275
  input: InferInput<TInput>;
276
- }) => Promise<TOutput extends z.ZodTypeAny ? z.infer<TOutput> : TResult>): convex_server0.RegisteredMutation<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredQuery<convex_server0.FunctionVisibility, Record<string, unknown>, unknown> | convex_server0.RegisteredAction<convex_server0.FunctionVisibility, Record<string, unknown>, unknown>;
276
+ }) => 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>;
277
277
  /** Mark as internal - returns chainable builder using internal function */
278
278
  internal(): ActionProcedureBuilder<TBaseCtx, TContext, TContextOverrides, TInput, TOutput, TMeta>;
279
279
  }
@@ -1,4 +1,4 @@
1
- import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-DxmuY355.js";
1
+ import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-CuyVsPAc.js";
2
2
  import { HttpRouter, httpActionGeneric } from "convex/server";
3
3
  import { ConvexError } from "convex/values";
4
4
  import { customCtx } from "convex-helpers/server/customFunctions";
@@ -1,4 +1,4 @@
1
- import { d as DeepPartial, f as DistributiveOmit, p as Simplify } from "./http-types-DAM81UvD.js";
1
+ import { d as DeepPartial, f as DistributiveOmit, p as Simplify } from "./http-types-DqMo3PY9.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";
package/dist/watcher.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_codegen = require('./codegen-CdL9lB4u.cjs');
2
+ const require_codegen = require('./codegen-ry3wEe7L.cjs');
3
3
  let node_path = require("node:path");
4
4
  node_path = require_codegen.__toESM(node_path);
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-convex",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Better Convex - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",