kitcn 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,16 +28,26 @@ const parseAuthConfig = (authConfig, opts) => {
28
28
  if (!isDataUriJwks && opts.jwks) console.warn("Static JWKS provided to Convex plugin, but not to auth config. This adds an unnecessary network request for token verification.");
29
29
  return providerConfig;
30
30
  };
31
- const convex = (opts) => {
32
- const jwtExpirationSeconds = opts.jwt?.expirationSeconds ?? opts.jwtExpirationSeconds ?? 900;
31
+ const oidcProviderCache = /* @__PURE__ */ new Map();
32
+ const getOidcProvider = (basePath) => {
33
+ const siteUrl = `${process.env.CONVEX_SITE_URL}`;
34
+ const key = `${siteUrl}|${basePath}`;
35
+ const cached = oidcProviderCache.get(key);
36
+ if (cached) return cached;
33
37
  const oidcProvider$1 = oidcProvider({
34
38
  loginPage: "/not-used",
35
39
  metadata: {
36
- issuer: `${process.env.CONVEX_SITE_URL}`,
37
- jwks_uri: `${process.env.CONVEX_SITE_URL}${opts.options?.basePath ?? "/api/auth"}/convex/jwks`
40
+ issuer: siteUrl,
41
+ jwks_uri: `${siteUrl}${basePath}/convex/jwks`
38
42
  },
39
43
  __skipDeprecationWarning: true
40
44
  });
45
+ oidcProviderCache.set(key, oidcProvider$1);
46
+ return oidcProvider$1;
47
+ };
48
+ const convex = (opts) => {
49
+ const jwtExpirationSeconds = opts.jwt?.expirationSeconds ?? opts.jwtExpirationSeconds ?? 900;
50
+ const oidcProvider = getOidcProvider(opts.options?.basePath ?? "/api/auth");
41
51
  const providerConfig = parseAuthConfig(opts.authConfig, opts);
42
52
  const jwtOptions = {
43
53
  jwt: {
@@ -128,7 +138,7 @@ const convex = (opts) => {
128
138
  })
129
139
  }],
130
140
  after: [
131
- ...normalizeAfterHooks(oidcProvider$1.hooks.after),
141
+ ...normalizeAfterHooks(oidcProvider.hooks.after),
132
142
  {
133
143
  matcher: (ctx) => {
134
144
  return Boolean(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/oauth2/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/phone-number/verify") || ctx.path?.startsWith("/siwe/verify") || ctx.path?.startsWith("/update-session") || ctx.path?.startsWith("/get-session") && ctx.context.session);
@@ -167,7 +177,7 @@ const convex = (opts) => {
167
177
  method: "GET",
168
178
  metadata: { isAction: false }
169
179
  }, async (ctx) => {
170
- return await oidcProvider$1.endpoints.getOpenIdConfig({
180
+ return await oidcProvider.endpoints.getOpenIdConfig({
171
181
  ...ctx,
172
182
  asResponse: false,
173
183
  returnHeaders: false,
@@ -1,9 +1,11 @@
1
1
  import { t as GetAuth } from "./types-BCl8gfGy.js";
2
2
  import { t as GenericCtx } from "./context-utils-BBUtBqjN.js";
3
3
  import * as convex_server0 from "convex/server";
4
- import { DocumentByName, FunctionReference, GenericDataModel, GenericMutationCtx, GenericSchema, SchemaDefinition, TableNamesInDataModel, internalMutationGeneric } from "convex/server";
4
+ import { DocumentByName, FunctionReference, GenericDataModel, GenericMutationCtx, GenericSchema, PaginationResult, SchemaDefinition, TableNamesInDataModel, internalMutationGeneric } from "convex/server";
5
5
  import * as better_auth_adapters0 from "better-auth/adapters";
6
+ import { BetterAuthDBSchema, getAuthTables } from "better-auth/db";
6
7
  import { BetterAuthOptions } from "better-auth/minimal";
8
+ import * as better_auth0 from "better-auth";
7
9
  import { Auth } from "better-auth";
8
10
 
9
11
  //#region src/auth/define-auth.d.ts
@@ -101,7 +103,7 @@ declare const findManyHandler: (ctx: any, args: {
101
103
  field: string;
102
104
  };
103
105
  where?: any[];
104
- }, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>;
106
+ }, schema: Schema, betterAuthSchema: any) => Promise<PaginationResult<convex_server0.GenericDocument>>;
105
107
  declare const updateOneHandler: (ctx: any, args: {
106
108
  input: {
107
109
  model: string;
@@ -155,6 +157,12 @@ declare const deleteManyHandler: (ctx: any, args: {
155
157
  declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel extends GenericDataModel = GenericDataModel, Ctx = unknown, TriggerCtx = Ctx, Auth = unknown>(schema: Schema, getAuth: GetAuth<Ctx, Auth>, options?: {
156
158
  internalMutation?: typeof internalMutationGeneric;
157
159
  context?: (ctx: any) => TriggerCtx | Promise<TriggerCtx>;
160
+ /**
161
+ * Ctx-free Better Auth table schema, memoized by the caller. Supplying it
162
+ * lets the runtime share one derivation with the db adapter instead of
163
+ * building a throwaway auth instance just to read `.options`.
164
+ */
165
+ getBetterAuthSchema?: () => ReturnType<typeof getAuthTables>;
158
166
  triggers?: GenericAuthTriggers<DataModel, Schema, TriggerCtx> | ((ctx: TriggerCtx) => GenericAuthTriggers<DataModel, Schema, TriggerCtx> | undefined); /** Validate input validators against auth table schemas. Defaults to false for smaller generated types. */
159
167
  validateInput?: boolean;
160
168
  }) => {
@@ -177,8 +185,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
177
185
  where?: {
178
186
  connector?: "AND" | "OR" | undefined;
179
187
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
180
- field: string;
181
188
  value: string | number | boolean | string[] | number[] | null;
189
+ field: string;
182
190
  }[] | undefined;
183
191
  model: string;
184
192
  } | {
@@ -206,8 +214,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
206
214
  where?: {
207
215
  connector?: "AND" | "OR" | undefined;
208
216
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
209
- field: string;
210
217
  value: string | number | boolean | string[] | number[] | null;
218
+ field: string;
211
219
  }[] | undefined;
212
220
  model: string;
213
221
  } | {
@@ -216,20 +224,20 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
216
224
  };
217
225
  }, Promise<Record<string, unknown> | undefined>>;
218
226
  findMany: convex_server0.RegisteredQuery<"internal", {
219
- limit?: number | undefined;
220
227
  join?: any;
221
- offset?: number | undefined;
222
- sortBy?: {
223
- field: string;
224
- direction: "asc" | "desc";
225
- } | undefined;
226
228
  where?: {
227
229
  mode?: "sensitive" | "insensitive" | undefined;
228
230
  connector?: "AND" | "OR" | undefined;
229
231
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
230
- field: string;
231
232
  value: string | number | boolean | string[] | number[] | null;
233
+ field: string;
232
234
  }[] | undefined;
235
+ limit?: number | undefined;
236
+ offset?: number | undefined;
237
+ sortBy?: {
238
+ field: string;
239
+ direction: "asc" | "desc";
240
+ } | undefined;
233
241
  model: string;
234
242
  paginationOpts: {
235
243
  id?: number;
@@ -239,7 +247,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
239
247
  numItems: number;
240
248
  cursor: string | null;
241
249
  };
242
- }, Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>>;
250
+ }, Promise<PaginationResult<convex_server0.GenericDocument>>>;
243
251
  findOne: convex_server0.RegisteredQuery<"internal", {
244
252
  join?: any;
245
253
  select?: string[] | undefined;
@@ -247,8 +255,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
247
255
  mode?: "sensitive" | "insensitive" | undefined;
248
256
  connector?: "AND" | "OR" | undefined;
249
257
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
250
- field: string;
251
258
  value: string | number | boolean | string[] | number[] | null;
259
+ field: string;
252
260
  }[] | undefined;
253
261
  model: string;
254
262
  }, Promise<convex_server0.GenericDocument | null>>;
@@ -259,8 +267,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
259
267
  where?: {
260
268
  connector?: "AND" | "OR" | undefined;
261
269
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
262
- field: string;
263
270
  value: string | number | boolean | string[] | number[] | null;
271
+ field: string;
264
272
  }[] | undefined;
265
273
  model: string;
266
274
  update: {
@@ -294,8 +302,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
294
302
  where?: {
295
303
  connector?: "AND" | "OR" | undefined;
296
304
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
297
- field: string;
298
305
  value: string | number | boolean | string[] | number[] | null;
306
+ field: string;
299
307
  }[] | undefined;
300
308
  model: string;
301
309
  update: {
@@ -325,13 +333,18 @@ type Triggers<DataModel extends GenericDataModel, Schema extends SchemaDefinitio
325
333
  type TriggerResolver<DataModel extends GenericDataModel, Schema extends SchemaDefinition<any, any>, TriggerCtx extends GenericMutationCtx<DataModel> = GenericMutationCtx<DataModel>> = Triggers<DataModel, Schema, TriggerCtx> | ((ctx: TriggerCtx) => Triggers<DataModel, Schema, TriggerCtx> | undefined);
326
334
  declare const createClient: <DataModel extends GenericDataModel, Schema extends SchemaDefinition<GenericSchema, true>, TriggerCtx extends GenericMutationCtx<DataModel> = GenericMutationCtx<DataModel>>(config: {
327
335
  authFunctions: AuthFunctions;
336
+ /**
337
+ * Ctx-free Better Auth table schema, memoized by the caller. Resolved lazily
338
+ * on the first db-adapter construction, never at module scope.
339
+ */
340
+ getBetterAuthSchema: () => BetterAuthDBSchema;
328
341
  schema: Schema;
329
342
  context?: (ctx: GenericMutationCtx<DataModel>) => TriggerCtx | Promise<TriggerCtx>;
330
343
  triggers?: TriggerResolver<DataModel, Schema, TriggerCtx>;
331
344
  }) => {
332
345
  authFunctions: AuthFunctions;
333
346
  triggers: TriggerResolver<DataModel, Schema, TriggerCtx> | undefined;
334
- adapter: (ctx: GenericCtx<DataModel>, getAuthOptions: (ctx: any) => BetterAuthOptions) => better_auth_adapters0.AdapterFactory<BetterAuthOptions>;
347
+ adapter: (ctx: GenericCtx<DataModel>) => better_auth_adapters0.AdapterFactory<better_auth0.BetterAuthOptions>;
335
348
  };
336
349
  //#endregion
337
350
  //#region src/auth/generated-contract-disabled.d.ts
@@ -1,4 +1,4 @@
1
- import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-BGBNBNit.js";
1
+ import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-B_H3oio5.js";
2
2
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.js";
3
3
  import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CNo9ffvI.js";
4
4
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { A as decodeJwtExp, C as useAuthValue, D as useIsAuth, E as useFetchAccessToken, O as useMaybeAuth, S as useAuthStore, T as useConvexAuthRecovery, _ as Unauthenticated, a as Authenticated, b as useAuthGuard, c as ConvexAuthRecoveryError, d as ConvexAuthRecoveryStatus, f as ConvexProviderWithAuth, g as MaybeUnauthenticated, h as MaybeAuthenticated, i as AuthStoreState, k as useSafeConvexAuth, l as ConvexAuthRecoveryErrorCode, m as FetchAccessTokenFn, n as AuthProvider, o as ConvexAuthBridge, p as FetchAccessTokenContext, r as AuthStore, s as ConvexAuthRecovery, t as AUTH_SESSION_SYNC_GRACE_MS, u as ConvexAuthRecoveryOptions, v as isSessionSyncGraceActive, w as useConvexAuthBridge, x as useAuthState, y as useAuth } from "../auth-store-47WTg13B.js";
2
+ import { A as decodeJwtExp, C as useAuthValue, D as useIsAuth, E as useFetchAccessToken, O as useMaybeAuth, S as useAuthStore, T as useConvexAuthRecovery, _ as Unauthenticated, a as Authenticated, b as useAuthGuard, c as ConvexAuthRecoveryError, d as ConvexAuthRecoveryStatus, f as ConvexProviderWithAuth, g as MaybeUnauthenticated, h as MaybeAuthenticated, i as AuthStoreState, k as useSafeConvexAuth, l as ConvexAuthRecoveryErrorCode, m as FetchAccessTokenFn, n as AuthProvider, o as ConvexAuthBridge, p as FetchAccessTokenContext, r as AuthStore, s as ConvexAuthRecovery, t as AUTH_SESSION_SYNC_GRACE_MS, u as ConvexAuthRecoveryOptions, v as isSessionSyncGraceActive, w as useConvexAuthBridge, x as useAuthState, y as useAuth } from "../auth-store-DHEk0ARa.js";
3
3
  import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, ConvexReactClientOptions, Watch, WatchQueryOptions, useConvex } from "convex/react";
4
4
  import { ReactNode } from "react";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
@@ -235,7 +235,6 @@ declare class ConvexQueryClient {
235
235
  private cancelPendingUnsubscribe;
236
236
  /** Unsubscribe a live Convex watch (if present) and remove it from the subscription map. */
237
237
  private unsubscribeQueryByHash;
238
- private isAuthBoundQuery;
239
238
  private subscribeQuery;
240
239
  /** Update auth store (for HMR where jotai store may reset) */
241
240
  updateAuthStore(authStore?: AuthStore): void;
@@ -271,6 +270,12 @@ declare class ConvexQueryClient {
271
270
  * Call before logout to prevent UNAUTHORIZED errors during session invalidation.
272
271
  */
273
272
  unsubscribeAuthQueries(): void;
273
+ /**
274
+ * Advance the account generation published by the auth store.
275
+ * Client state that only makes sense inside one account's result set —
276
+ * paginated cursor chains — keys on it, so it is rebuilt instead of reused.
277
+ */
278
+ private bumpAuthEpoch;
274
279
  resetAuthQueries(): Promise<void>;
275
280
  /**
276
281
  * Batch update all subscriptions.
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { A as CRPCClientError, C as decodeJwtExp, M as isCRPCClientError, O as writeAuthSessionFallbackData, S as useSafeConvexAuth, T as clearAuthSessionFallback, _ as useConvexAuthBridge, a as ConvexAuthRecoveryError, b as useIsAuth, c as MaybeAuthenticated, d as isSessionSyncGraceActive, f as useAuth, g as useAuthValue, h as useAuthStore, i as ConvexAuthBridge, j as defaultIsUnauthorized, k as writeAuthSessionFallbackToken, l as MaybeUnauthenticated, m as useAuthState, n as AuthProvider, o as ConvexProviderWithAuth, p as useAuthGuard, r as Authenticated, s as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS, u as Unauthenticated, v as useConvexAuthRecovery, w as decodeJwtIdentity, x as useMaybeAuth, y as useFetchAccessToken } from "../auth-store-BHk8eMnX.js";
2
+ import { A as CRPCClientError, C as decodeJwtExp, M as isCRPCClientError, O as writeAuthSessionFallbackData, S as useSafeConvexAuth, T as clearAuthSessionFallback, _ as useConvexAuthBridge, a as ConvexAuthRecoveryError, b as useIsAuth, c as MaybeAuthenticated, d as isSessionSyncGraceActive, f as useAuth, g as useAuthValue, h as useAuthStore, i as ConvexAuthBridge, j as defaultIsUnauthorized, k as writeAuthSessionFallbackToken, l as MaybeUnauthenticated, m as useAuthState, n as AuthProvider, o as ConvexProviderWithAuth, p as useAuthGuard, r as Authenticated, s as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS, u as Unauthenticated, v as useConvexAuthRecovery, w as decodeJwtIdentity, x as useMaybeAuth, y as useFetchAccessToken } from "../auth-store-BnsWs1xd.js";
3
3
  import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, useAction, useConvex, useMutation } from "convex/react";
4
4
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
@@ -1647,7 +1647,6 @@ function createAuthMutations(authClient) {
1647
1647
  });
1648
1648
  const useSignInSocialMutationOptions = ((options) => {
1649
1649
  const authStoreApi = useAuthStore();
1650
- const convexQueryClient = useConvexQueryClient();
1651
1650
  return {
1652
1651
  ...options,
1653
1652
  mutationFn: async (args) => {
@@ -1659,14 +1658,12 @@ function createAuthMutations(authClient) {
1659
1658
  await hydrateReturnedSession(authClient, res);
1660
1659
  await ensureAuth(authStoreApi);
1661
1660
  authStoreApi.set("isAuthenticated", true);
1662
- await convexQueryClient?.resetAuthQueries();
1663
1661
  return res;
1664
1662
  }
1665
1663
  };
1666
1664
  });
1667
1665
  const useSignInMutationOptions = ((options) => {
1668
1666
  const authStoreApi = useAuthStore();
1669
- const convexQueryClient = useConvexQueryClient();
1670
1667
  const { signInMethod = "email", ...mutationOptions } = options ?? {};
1671
1668
  return {
1672
1669
  ...mutationOptions,
@@ -1679,14 +1676,12 @@ function createAuthMutations(authClient) {
1679
1676
  await hydrateReturnedSession(authClient, res);
1680
1677
  await ensureAuth(authStoreApi);
1681
1678
  authStoreApi.set("isAuthenticated", true);
1682
- await convexQueryClient?.resetAuthQueries();
1683
1679
  return res;
1684
1680
  }
1685
1681
  };
1686
1682
  });
1687
1683
  const useSignUpMutationOptions = ((options) => {
1688
1684
  const authStoreApi = useAuthStore();
1689
- const convexQueryClient = useConvexQueryClient();
1690
1685
  return {
1691
1686
  ...options,
1692
1687
  mutationFn: async (args) => {
@@ -1698,7 +1693,6 @@ function createAuthMutations(authClient) {
1698
1693
  await hydrateReturnedSession(authClient, res);
1699
1694
  await ensureAuth(authStoreApi);
1700
1695
  authStoreApi.set("isAuthenticated", true);
1701
- await convexQueryClient?.resetAuthQueries();
1702
1696
  return res;
1703
1697
  }
1704
1698
  };
@@ -1711,6 +1705,81 @@ function createAuthMutations(authClient) {
1711
1705
  };
1712
1706
  }
1713
1707
 
1708
+ //#endregion
1709
+ //#region src/internal/auth-reset.ts
1710
+ /**
1711
+ * Erase the cached result of every auth-bound query.
1712
+ *
1713
+ * `queryClient.resetQueries()` is not enough. It restores each query's
1714
+ * `initialState`, and query-core derives that from `initialData` when the query
1715
+ * is built, never re-deriving it once real data lands. An auth-bound entry
1716
+ * therefore comes back holding the previous account's rows marked `success`,
1717
+ * and nothing corrects it: Convex query options set `staleTime: Infinity` with
1718
+ * every refetch trigger off, and `resetQueries` only refetches entries that are
1719
+ * currently active.
1720
+ *
1721
+ * Every entry is removed so query-core forgets both its current state and its
1722
+ * private `initialState`. Mounted observers are rebound with `initialData`
1723
+ * removed, creating a pristine replacement query that future public resets
1724
+ * cannot use to resurrect the previous account's rows.
1725
+ */
1726
+ async function clearAuthBoundQueries(cache, isAuthBound) {
1727
+ const authQueries = cache.getAll().filter((query) => isAuthBound(query));
1728
+ const restoreObservers = [];
1729
+ await Promise.all(authQueries.map((query) => query.cancel({ silent: true })));
1730
+ for (const query of authQueries) {
1731
+ const observers = [...query.observers];
1732
+ cache.remove(query);
1733
+ for (const observer of observers) {
1734
+ const previousOptions = observer.options;
1735
+ observer.setOptions({
1736
+ ...observer.options,
1737
+ enabled: false,
1738
+ initialData: void 0,
1739
+ placeholderData: void 0
1740
+ });
1741
+ const suspendedOptions = observer.options;
1742
+ restoreObservers.push(() => {
1743
+ const currentOptions = observer.options;
1744
+ observer.setOptions({
1745
+ ...currentOptions,
1746
+ enabled: observer.options === suspendedOptions ? previousOptions.enabled : currentOptions.enabled,
1747
+ initialData: void 0,
1748
+ placeholderData: void 0
1749
+ });
1750
+ });
1751
+ }
1752
+ }
1753
+ return () => {
1754
+ for (const restoreObserver of restoreObservers) restoreObserver();
1755
+ };
1756
+ }
1757
+
1758
+ //#endregion
1759
+ //#region src/internal/subscription-gate.ts
1760
+ /** Read kitcn's meta off a TanStack query. */
1761
+ function readConvexQueryMeta(query) {
1762
+ return query.meta;
1763
+ }
1764
+ /**
1765
+ * Auth-bound queries are cleared and resubscribed on an identity transition so
1766
+ * one account never renders another account's cached rows.
1767
+ */
1768
+ function isAuthBoundQuery(query) {
1769
+ const authType = readConvexQueryMeta(query)?.authType;
1770
+ return authType === "required" || authType === "optional";
1771
+ }
1772
+ /** Whether a Convex subscription may be opened for this query. */
1773
+ function canSubscribeQuery(query, opts) {
1774
+ if (opts.isSubscribed) return false;
1775
+ const meta = readConvexQueryMeta(query);
1776
+ if (meta?.subscribe === false) return false;
1777
+ if (query.getObserversCount() === 0) return false;
1778
+ if (query.isDisabled()) return false;
1779
+ if (opts.shouldSkipSubscription(meta?.authType)) return false;
1780
+ return true;
1781
+ }
1782
+
1714
1783
  //#endregion
1715
1784
  //#region src/react/client.ts
1716
1785
  /**
@@ -1882,17 +1951,11 @@ var ConvexQueryClient = class {
1882
1951
  sub.unsubscribe();
1883
1952
  delete this.subscriptions[queryHash];
1884
1953
  }
1885
- isAuthBoundQuery(query) {
1886
- const meta = query.meta;
1887
- return meta?.authType === "required" || meta?.authType === "optional";
1888
- }
1889
1954
  subscribeQuery(query) {
1890
- if (this.subscriptions[query.queryHash]) return;
1891
- const meta = query.meta;
1892
- if (meta?.subscribe === false) return;
1893
- if (query.getObserversCount() === 0) return;
1894
- if (query.isDisabled()) return;
1895
- if (this.shouldSkipSubscription(meta?.authType)) return;
1955
+ if (!canSubscribeQuery(query, {
1956
+ isSubscribed: !!this.subscriptions[query.queryHash],
1957
+ shouldSkipSubscription: (authType) => this.shouldSkipSubscription(authType)
1958
+ })) return;
1896
1959
  const [, funcName, args] = query.queryKey;
1897
1960
  const watch = this.convexClient.watchQuery(funcName, this.transformer.input.serialize(args));
1898
1961
  const unsubscribe = watch.onUpdate(() => {
@@ -1986,14 +2049,29 @@ var ConvexQueryClient = class {
1986
2049
  this.unsubscribeQueryByHash(queryHash);
1987
2050
  }
1988
2051
  }
2052
+ /**
2053
+ * Advance the account generation published by the auth store.
2054
+ * Client state that only makes sense inside one account's result set —
2055
+ * paginated cursor chains — keys on it, so it is rebuilt instead of reused.
2056
+ */
2057
+ bumpAuthEpoch() {
2058
+ if (!this.authStore) return;
2059
+ this.authStore.set("authEpoch", this.authStore.get("authEpoch") + 1);
2060
+ }
1989
2061
  async resetAuthQueries() {
1990
- const authQueries = this.queryClient.getQueryCache().getAll().filter((query) => this.isAuthBoundQuery(query));
1991
- for (const query of authQueries) {
2062
+ const queryCache = this.queryClient.getQueryCache();
2063
+ for (const query of queryCache.getAll()) {
2064
+ if (!isAuthBoundQuery(query)) continue;
1992
2065
  this.cancelPendingUnsubscribe(query.queryHash);
1993
2066
  this.unsubscribeQueryByHash(query.queryHash);
1994
2067
  }
1995
- await this.queryClient.resetQueries({ predicate: (query) => this.isAuthBoundQuery(query) });
1996
- for (const query of this.queryClient.getQueryCache().getAll()) if (this.isAuthBoundQuery(query)) this.subscribeQuery(query);
2068
+ this.bumpAuthEpoch();
2069
+ (await clearAuthBoundQueries(queryCache, (query) => isAuthBoundQuery(query)))();
2070
+ await this.queryClient.refetchQueries({
2071
+ predicate: (query) => isAuthBoundQuery(query),
2072
+ type: "active"
2073
+ });
2074
+ for (const query of queryCache.getAll()) if (isAuthBoundQuery(query)) this.subscribeQuery(query);
1997
2075
  }
1998
2076
  /**
1999
2077
  * Batch update all subscriptions.
@@ -2270,15 +2348,8 @@ const shouldSplitPaginationPage = (page, initialNumItems) => Boolean(page.splitC
2270
2348
  //#region src/react/use-infinite-query.ts
2271
2349
  /** biome-ignore-all lint/suspicious/noExplicitAny: Convex query/mutation type compatibility */
2272
2350
  const PAGINATION_KEY_PREFIX = "__pagination__";
2273
- const paginationIdStore = /* @__PURE__ */ new Map();
2274
2351
  let paginationIdCounter = 0;
2275
- const getOrCreatePaginationId = (storeKey) => {
2276
- const existing = paginationIdStore.get(storeKey);
2277
- if (existing !== void 0) return existing;
2278
- const newId = ++paginationIdCounter;
2279
- paginationIdStore.set(storeKey, newId);
2280
- return newId;
2281
- };
2352
+ const createPaginationId = () => ++paginationIdCounter;
2282
2353
  /** Build a unique key for recovery attempt detection */
2283
2354
  const buildRecoveryKey = (pageKeys, page0Cursor, page0UpdatedAt) => JSON.stringify({
2284
2355
  pageKeys,
@@ -2360,12 +2431,13 @@ const useStaleCursorRecovery = ({ argsObject, combined, limit, setState, state }
2360
2431
  * Use `useInfiniteQuery` for the public API with auth handling.
2361
2432
  */
2362
2433
  const useInfiniteQueryInternal = (query, args, options) => {
2363
- const { limit, enabled, placeholderData, ...forwardedOptions } = options;
2434
+ const { limit, authType, enabled, placeholderData, ...forwardedOptions } = options;
2364
2435
  const queryOptions = useStableIdentity(forwardedOptions);
2365
2436
  const { isLoading: isAuthLoading } = useSafeConvexAuth();
2366
2437
  const meta = useMeta();
2367
2438
  const queryClient = useQueryClient();
2368
- const prefetchedFirstPage = useMemo(() => {
2439
+ const authEpoch = useAuthValue("authEpoch");
2440
+ const skip = !useMemo(() => {
2369
2441
  const serverQueryKey = [
2370
2442
  "convexQuery",
2371
2443
  getFunctionName(query),
@@ -2381,8 +2453,7 @@ const useInfiniteQueryInternal = (query, args, options) => {
2381
2453
  JSON.stringify(args),
2382
2454
  limit,
2383
2455
  queryClient
2384
- ]);
2385
- const skip = !prefetchedFirstPage && (isAuthLoading || enabled === false);
2456
+ ]) && (isAuthLoading || enabled === false);
2386
2457
  const getPaginationState = useCallback((key) => {
2387
2458
  const queryKey = [PAGINATION_KEY_PREFIX, key];
2388
2459
  return queryClient.getQueryData(queryKey);
@@ -2394,10 +2465,16 @@ const useInfiniteQueryInternal = (query, args, options) => {
2394
2465
  const argsObject = useMemo(() => skip ? {} : args, [skip, JSON.stringify(args)]);
2395
2466
  const storeKey = useMemo(() => JSON.stringify({
2396
2467
  query: getFunctionName(query),
2397
- args: argsObject
2398
- }), [query, argsObject]);
2468
+ args: argsObject,
2469
+ ...authType ? { authEpoch } : {}
2470
+ }), [
2471
+ query,
2472
+ argsObject,
2473
+ authType,
2474
+ authEpoch
2475
+ ]);
2399
2476
  const createInitialState = useCallback(() => {
2400
- const id = getOrCreatePaginationId(storeKey);
2477
+ const id = createPaginationId();
2401
2478
  return {
2402
2479
  id,
2403
2480
  nextPageKey: 1,
@@ -2411,7 +2488,6 @@ const useInfiniteQueryInternal = (query, args, options) => {
2411
2488
  version: 0
2412
2489
  };
2413
2490
  }, [
2414
- storeKey,
2415
2491
  skip,
2416
2492
  argsObject,
2417
2493
  limit
@@ -2484,10 +2560,9 @@ const useInfiniteQueryInternal = (query, args, options) => {
2484
2560
  const pageArgs = state.queries[key]?.args;
2485
2561
  return {
2486
2562
  ...convexQuery(query, pageArgs ? (({ __paginationId, ...rest }) => rest)(pageArgs) : "skip", meta),
2487
- enabled: resolveEnabled(!skip && !!state.queries[key], enabled),
2563
+ enabled: resolveEnabled(!skip && !!state.queries[key] && (!authType || !isAuthLoading), enabled),
2488
2564
  structuralSharing: false,
2489
2565
  ...queryOptions ?? {},
2490
- ...index === 0 && prefetchedFirstPage ? { initialData: prefetchedFirstPage } : {},
2491
2566
  ...index === 0 && placeholderData ? { placeholderData: {
2492
2567
  page: placeholderData,
2493
2568
  isDone: false,
@@ -2502,7 +2577,6 @@ const useInfiniteQueryInternal = (query, args, options) => {
2502
2577
  enabled,
2503
2578
  meta,
2504
2579
  queryOptions,
2505
- prefetchedFirstPage,
2506
2580
  placeholderData
2507
2581
  ]),
2508
2582
  combine: useCallback((results) => {
@@ -2689,6 +2763,7 @@ function useInfiniteQuery(infiniteOptions) {
2689
2763
  ]);
2690
2764
  const enabled = useMemo(() => resolveEnabled(!shouldSkip, factoryEnabled), [shouldSkip, factoryEnabled]);
2691
2765
  const result = useInfiniteQueryInternal(query, args, {
2766
+ authType,
2692
2767
  limit,
2693
2768
  ...queryOptions,
2694
2769
  enabled
@@ -210,11 +210,15 @@ declare const FetchAccessTokenContext: solid_js0.Context<FetchAccessTokenFn | nu
210
210
  /** Get fetchAccessToken from context (available immediately, no race condition) */
211
211
  declare const useFetchAccessToken: () => FetchAccessTokenFn | null;
212
212
  type ConvexAuthResult = {
213
+ identity: unknown;
213
214
  isAuthenticated: boolean;
214
215
  isLoading: boolean;
215
216
  };
217
+ type ConvexAuthBridgeResult = ConvexAuthResult & {
218
+ authEpoch: number;
219
+ };
216
220
  /** Get auth from bridge context (null if no bridge configured) */
217
- declare const useConvexAuthBridge: () => ConvexAuthResult | null;
221
+ declare const useConvexAuthBridge: () => ConvexAuthBridgeResult | null;
218
222
  type AuthStoreState = {
219
223
  /** Callback when mutation/action called while unauthorized. Throws by default. */onMutationUnauthorized: () => void; /** Callback when query called while unauthorized. Noop by default. */
220
224
  onQueryUnauthorized: (info: {
@@ -225,6 +229,12 @@ type AuthStoreState = {
225
229
  expiresAt: number | null; /** Auth loading state (synced from useConvexAuth for class methods) */
226
230
  isLoading: boolean; /** Auth state (synced from useConvexAuth for class methods) */
227
231
  isAuthenticated: boolean;
232
+ /**
233
+ * Account generation, advanced on every identity transition. Client state
234
+ * that only makes sense inside one account's result set — paginated cursor
235
+ * chains — keys on it so it is rebuilt instead of reused across accounts.
236
+ */
237
+ authEpoch: number;
228
238
  };
229
239
  /** Decode JWT expiration (ms timestamp) from token */
230
240
  declare function decodeJwtExp(token: string): number | null;
@@ -258,6 +268,8 @@ declare function useSafeConvexAuth(): ConvexAuthResult;
258
268
  * @internal
259
269
  */
260
270
  declare function ConvexAuthBridge(props: ParentProps<{
271
+ authEpoch?: number;
272
+ identity?: unknown;
261
273
  isLoading: boolean;
262
274
  isAuthenticated: boolean;
263
275
  }>): JSX.Element;
@@ -369,6 +381,12 @@ declare class ConvexQueryClient {
369
381
  ssrQueryMode: 'consistent' | 'inconsistent';
370
382
  /** Auth store for checking auth state */
371
383
  private authStore?;
384
+ /** In-flight clear shared by overlapping account identity transitions. */
385
+ private authBarrierClear?;
386
+ /** Blocks auth-bound work created while Convex is changing identity. */
387
+ private authSettlementBarrier?;
388
+ /** Latest account transition allowed to restore and refetch observers. */
389
+ private authResetGeneration;
372
390
  /** Delay before unsubscribing when query has no observers */
373
391
  private unsubscribeDelay;
374
392
  /** Payload transformer used across request/response boundaries. */
@@ -381,6 +399,11 @@ declare class ConvexQueryClient {
381
399
  private cancelPendingUnsubscribe;
382
400
  /** Unsubscribe a live Convex subscription (if present) and remove it from the subscription map. */
383
401
  private unsubscribeQueryByHash;
402
+ /**
403
+ * Open a Convex subscription for a query, if the shared gate allows it.
404
+ * Single owner of the subscribe preconditions for every cache-event branch.
405
+ */
406
+ private subscribeQuery;
384
407
  /** Update auth store (for HMR where store may reset) */
385
408
  updateAuthStore(authStore?: AuthStore): void;
386
409
  /** Get current auth state from store */
@@ -390,6 +413,10 @@ declare class ConvexQueryClient {
390
413
  * Needed for useSuspenseQuery which ignores enabled: false.
391
414
  */
392
415
  private shouldSkipSubscription;
416
+ /** Hold new auth-bound requests until the latest Convex identity settles. */
417
+ private beginAuthSettlementBarrier;
418
+ /** Wait through overlapping barriers and stop canceled requests. */
419
+ private waitForAuthSettlement;
393
420
  /** Get QueryClient, throwing if not connected */
394
421
  get queryClient(): QueryClient;
395
422
  /**
@@ -414,6 +441,25 @@ declare class ConvexQueryClient {
414
441
  * Call before logout to prevent UNAUTHORIZED errors during session invalidation.
415
442
  */
416
443
  unsubscribeAuthQueries(): void;
444
+ /**
445
+ * Advance the account generation published by the auth store.
446
+ * Client state that only makes sense inside one account's result set —
447
+ * paginated cursor chains — keys on it, so it is rebuilt instead of reused.
448
+ */
449
+ private bumpAuthEpoch;
450
+ /** Drop auth-bound data without fetching while Convex changes identity. */
451
+ private clearAuthQueries;
452
+ /** Refetch and resubscribe auth-bound queries after Convex settles. */
453
+ private refetchAuthQueries;
454
+ /**
455
+ * Drop every auth-bound cache entry and resubscribe.
456
+ * Call after an identity transition when no separate settlement barrier owns
457
+ * the clear/refetch phases.
458
+ */
459
+ resetAuthQueries(options?: {
460
+ generation?: number;
461
+ refetch?: boolean;
462
+ }): Promise<number>;
417
463
  /**
418
464
  * Batch update all subscriptions.
419
465
  * Called internally when Convex client reconnects.
@@ -1271,6 +1317,7 @@ declare function ConvexProvider(props: ParentProps<{
1271
1317
  declare function ConvexProviderWithAuth(props: ParentProps<{
1272
1318
  client: ConvexClient;
1273
1319
  useAuth: () => {
1320
+ /** Stable account/session identity. Token refreshes must keep this value. */identity?: string | null;
1274
1321
  isLoading: boolean;
1275
1322
  isAuthenticated: boolean;
1276
1323
  fetchAccessToken: AuthTokenFetcher;
@@ -1477,7 +1524,9 @@ declare function useConvexInfiniteQueryOptions<T extends FunctionReference<'quer
1477
1524
  */
1478
1525
  declare function useConvexActionQueryOptions<Action extends FunctionReference<'action'>>(action: Action, args: FunctionArgs<Action> | SkipToken, options?: {
1479
1526
  skipUnauth?: boolean;
1480
- } & DistributiveOmit<SolidQueryOptions<FunctionReturnType<Action>, DefaultError>, ReservedQueryOptions>): ConvexActionOptions<Action>;
1527
+ } & DistributiveOmit<SolidQueryOptions<FunctionReturnType<Action>, DefaultError>, ReservedQueryOptions>): ConvexActionOptions<Action> & {
1528
+ meta: ConvexQueryMeta;
1529
+ };
1481
1530
  /**
1482
1531
  * Hook that returns mutation options for use with useMutation.
1483
1532
  * Wraps the Convex mutation with auth guard logic.