kitcn 0.33.7 → 0.33.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # kitcn
2
2
 
3
+ ## 0.33.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#478](https://github.com/udecode/kitcn/pull/478) [`03b1ad1`](https://github.com/udecode/kitcn/commit/03b1ad1bd72333ce3867f79d8f079193cf77c170) Thanks [@zbeyens](https://github.com/zbeyens)! - ## Patches
8
+
9
+ - Support app-owned synchronous or asynchronous JWT cache clocks for Next.js partial prefetching and private-cache rendering.
10
+
3
11
  ## 0.33.7
4
12
 
5
13
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import { Vn as ConvexTextBuilderInitial, Zt as ConvexTableWithColumns } from "../capabilities-Bxzoofl4.js";
2
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-DAqhUREe.js";
2
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-CTblNxLo.js";
3
3
  import * as convex_values0 from "convex/values";
4
4
  import { GenericId, Infer, Value } from "convex/values";
5
5
  import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
@@ -1,2 +1,2 @@
1
- import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, b as GenericAuthBeforeResult, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../../generated-contract-disabled-QZXEzUnd.js";
1
+ import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, b as GenericAuthBeforeResult, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../../generated-contract-disabled-CFLQf8Wg.js";
2
2
  export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
@@ -1,7 +1,7 @@
1
1
  import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-BkNjkDCk.js";
2
2
  import { t as GetAuth } from "../types-ex0-J-SC.js";
3
3
  import { t as GenericCtx } from "../context-utils-Cbv4r0AA.js";
4
- import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, _ as updateManyHandler, a as AuthFunctions, b as GenericAuthBeforeResult, c as consumeOneHandler, d as createHandler, f as deleteManyHandler, g as incrementOneHandler, h as findOneHandler, i as getGeneratedAuthDisabledReason, l as countHandler, m as findManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as deleteOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createApi, v as updateOneHandler, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../generated-contract-disabled-QZXEzUnd.js";
4
+ import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, _ as updateManyHandler, a as AuthFunctions, b as GenericAuthBeforeResult, c as consumeOneHandler, d as createHandler, f as deleteManyHandler, g as incrementOneHandler, h as findOneHandler, i as getGeneratedAuthDisabledReason, l as countHandler, m as findManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as deleteOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createApi, v as updateOneHandler, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../generated-contract-disabled-CFLQf8Wg.js";
5
5
  import * as convex_values0 from "convex/values";
6
6
  import { Infer } from "convex/values";
7
7
  import { AuthConfig, DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
@@ -132,8 +132,8 @@ declare const adapterArgsValidator: convex_values0.VObject<{
132
132
  select?: string[] | undefined;
133
133
  offset?: number | undefined;
134
134
  sortBy?: {
135
- direction: "asc" | "desc";
136
135
  field: string;
136
+ direction: "asc" | "desc";
137
137
  } | undefined;
138
138
  model: string;
139
139
  }, {
@@ -142,12 +142,12 @@ declare const adapterArgsValidator: convex_values0.VObject<{
142
142
  offset: convex_values0.VFloat64<number | undefined, "optional">;
143
143
  select: convex_values0.VArray<string[] | undefined, convex_values0.VString<string, "required">, "optional">;
144
144
  sortBy: convex_values0.VObject<{
145
- direction: "asc" | "desc";
146
145
  field: string;
146
+ direction: "asc" | "desc";
147
147
  } | undefined, {
148
148
  direction: convex_values0.VUnion<"asc" | "desc", [convex_values0.VLiteral<"asc", "required">, convex_values0.VLiteral<"desc", "required">], "required", never>;
149
149
  field: convex_values0.VString<string, "required">;
150
- }, "optional", "direction" | "field">;
150
+ }, "optional", "field" | "direction">;
151
151
  where: convex_values0.VArray<{
152
152
  mode?: "sensitive" | "insensitive" | undefined;
153
153
  operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
@@ -167,7 +167,7 @@ declare const adapterArgsValidator: convex_values0.VObject<{
167
167
  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>;
168
168
  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>;
169
169
  }, "required", "mode" | "operator" | "value" | "field" | "connector">, "optional">;
170
- }, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.direction" | "sortBy.field">;
170
+ }, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
171
171
  declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
172
172
  declare const checkUniqueFields: <Schema extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
173
173
  declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
@@ -1,11 +1,11 @@
1
1
  import { H as ConvexContext, W as LazyCaller } from "../../procedure-name-DRSOwAJY.js";
2
- import { t as GetTokenOptions } from "../../token-tlbNKQS0.js";
2
+ import { t as GetTokenOptions } from "../../token-COZD00dG.js";
3
3
 
4
4
  //#region src/auth-nextjs/index.d.ts
5
5
  /** Auth options for server-side calls. */
6
6
  type AuthOptions = {
7
- /** Better Auth auth route base path. Defaults to `/api/auth`. */basePath?: string; /** Enable/disable JWT caching. Default: true */
8
- jwtCache?: boolean; /** Custom function to detect UNAUTHORIZED errors. Default checks code property. */
7
+ /** Better Auth auth route base path. Defaults to `/api/auth`. */basePath?: string; /** Enable/disable JWT caching or provide a Unix-seconds clock. Default: true. */
8
+ jwtCache?: boolean | Pick<NonNullable<GetTokenOptions['jwtCache']>, 'now'>; /** Custom function to detect UNAUTHORIZED errors. Default checks code property. */
9
9
  isUnauthorized?: (error: unknown) => boolean; /** Expiration tolerance in seconds. */
10
10
  expirationToleranceSeconds?: number;
11
11
  };
@@ -1,4 +1,4 @@
1
- import { t as getToken } from "../../token-CgIvcEZX.js";
1
+ import { t as getToken } from "../../token-CZbuEcTL.js";
2
2
  import { n as defaultIsUnauthorized } from "../../error-CLgc9khF.js";
3
3
  import { t as createCallerFactory } from "../../caller-factory-CEKbQdGY.js";
4
4
 
@@ -80,7 +80,8 @@ function convexBetterAuth(opts) {
80
80
  jwtCache: {
81
81
  enabled: jwtCacheEnabled,
82
82
  expirationToleranceSeconds: auth.expirationToleranceSeconds,
83
- isAuthError: auth.isUnauthorized ?? defaultIsUnauthorized
83
+ isAuthError: auth.isUnauthorized ?? defaultIsUnauthorized,
84
+ now: typeof auth.jwtCache === "object" ? auth.jwtCache.now : void 0
84
85
  }
85
86
  });
86
87
  },
@@ -1,5 +1,5 @@
1
1
  import { H as ConvexContext, W as LazyCaller } from "../../../procedure-name-DRSOwAJY.js";
2
- import { t as GetTokenOptions } from "../../../token-tlbNKQS0.js";
2
+ import { t as GetTokenOptions } from "../../../token-COZD00dG.js";
3
3
  import { FunctionReference, FunctionReturnType, OptionalRestArgs } from "convex/server";
4
4
 
5
5
  //#region src/auth-start/server.d.ts
@@ -1,4 +1,4 @@
1
- import { t as getToken } from "../../../token-CgIvcEZX.js";
1
+ import { t as getToken } from "../../../token-CZbuEcTL.js";
2
2
  import { n as defaultIsUnauthorized } from "../../../error-CLgc9khF.js";
3
3
  import { t as createCallerFactory } from "../../../caller-factory-CEKbQdGY.js";
4
4
  import { stripIndent } from "common-tags";
@@ -289,8 +289,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
289
289
  }[] | undefined;
290
290
  offset?: number | undefined;
291
291
  sortBy?: {
292
- direction: "asc" | "desc";
293
292
  field: string;
293
+ direction: "asc" | "desc";
294
294
  } | undefined;
295
295
  paginationOpts: {
296
296
  id?: number;
@@ -1,5 +1,5 @@
1
1
  import { $n as TableName, $t as OrmLifecycleChange, An as ConvexCheckBuilder, At as UpdateSet, Bn as ConvexTextBuilder, Br as IsPrimaryKey, Bt as RelationsBuilderColumnBase, C as MigrationStep, Cn as ConvexVectorIndexConfig, Cr as not, Ct as OrderByClause, D as defineMigration, Dn as searchIndex, Dr as startsWith, Dt as ReturningAll, E as buildMigrationPlan, En as rankIndex, Er as or, Et as PredicateWhereIndexConfig, Fn as ConvexUniqueConstraintBuilderOn, Fr as ColumnBuilderTypeConfig, Ft as ExtractTablesFromSchema, Gn as Columns, Gt as TablesRelationalConfig, H as RlsMode, Hn as text, Hr as NotNull, In as ConvexUniqueConstraintConfig, Ir as ColumnBuilderWithTableName, It as ExtractTablesWithRelations, Jn as OrmSchemaExtensionTables, Jt as ConvexDeletionBuilder, Kt as defineRelations, Ln as check, Lr as ColumnDataType, Lt as ManyConfig, M as DatabaseWithQuery, Mn as ConvexForeignKeyBuilder, Mr as ColumnBuilder, Mt as VectorSearchProvider, N as OrmReader$1, Nn as ConvexForeignKeyConfig, Nr as ColumnBuilderBaseConfig, Nt as unsetToken, O as defineMigrationSet, On as uniqueIndex, Ot as ReturningResult, P as OrmWriter$1, Pn as ConvexUniqueConstraintBuilder, Pr as ColumnBuilderRuntimeConfig, Qn as OrmSchemaTriggers, Qt as DiscriminatorBuilderConfig, Rn as foreignKey, Rr as DrizzleEntity, Rt as OneConfig, S as MigrationStateMap, Sn as ConvexVectorIndexBuilderOn, Sr as ne, St as MutationRunMode, T as MigrationWriteMode, Tn as index, Tr as notInArray, Tt as PaginatedResult, U as EdgeMetadata, V as RlsContext, Vn as ConvexTextBuilderInitial, Vr as IsUnique, Vt as RelationsBuilderColumnConfig, W as extractRelationsConfig, Wn as Brand, Wt as TableRelationalConfig, Xn as OrmSchemaExtensions, Xt as ConvexTable, Yt as ConvexDeletionConfig, Zn as OrmSchemaRelations, Zt as ConvexTableWithColumns, _ as MigrationManifestEntry, _n as ConvexRankIndexBuilderOn, _r as isNotNull, _t as MutationExecutionMode, an as RlsPolicy, ar as UnaryExpression, at as BuildRelationResult, b as MigrationRunStatus, bn as ConvexSearchIndexConfig, br as lt, bt as MutationResult, cn as rlsPolicy, cr as contains, ct as DBQueryConfig, d as MigrationAppliedState, dn as rlsRole, dr as fieldRef, dt as InferInsertModel, en as OrmLifecycleOperation, er as BinaryExpression, f as MigrationDefinition, fn as ConvexAggregateIndexBuilder, fr as gt, ft as InferModelFromColumns, g as MigrationDriftIssue, gn as ConvexRankIndexBuilder, gr as isFieldReference, gt as MutationExecuteResult, h as MigrationDocContext, hn as ConvexIndexBuilderOn, hr as inArray, ht as MutationExecuteConfig, i as OrmMigrationCapability, in as discriminator, ir as LogicalExpression, it as BuildQueryResult, j as DatabaseWithMutations, jn as ConvexCheckConfig, jr as AnyColumn, jt as VectorQueryConfig, k as detectMigrationDrift, kn as vectorIndex, kr as SystemFields, kt as ReturningSelection, ln as RlsRole, lr as endsWith, lt as FilterOperators, m as MigrationDoc, mn as ConvexIndexBuilder, mr as ilike, mt as InsertValue, n as OrmCapabilities, nn as convexTable, nr as FieldReference, nt as AggregateFieldValue, on as RlsPolicyConfig, or as and, ot as CountConfig, p as MigrationDirection, pn as ConvexAggregateIndexBuilderOn, pr as gte, pt as InferSelectModel, qt as defineRelationsPart, r as OrmCapability, rn as deletion, rr as FilterExpression, rt as AggregateResult, sn as RlsPolicyToOption, sr as between, st as CountResult, t as OrmAggregateCapability, tn as TableConfig, tr as ExpressionVisitor, tt as AggregateConfig, un as RlsRoleConfig, ur as eq, ut as GetColumnData, v as MigrationMigrateOne, vn as ConvexSearchIndexBuilder, vr as isNull, vt as MutationPaginateConfig, w as MigrationTableName, wn as aggregateIndex, wr as notBetween, wt as OrderDirection, x as MigrationSet, xn as ConvexVectorIndexBuilder, xr as lte, xt as MutationReturning, y as MigrationPlan, yn as ConvexSearchIndexBuilderOn, yr as like, yt as MutationPaginatedResult, zn as unique, zr as HasDefault, zt as RelationsBuilder } from "../capabilities-Bxzoofl4.js";
2
- import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-DAqhUREe.js";
2
+ import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-CTblNxLo.js";
3
3
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-0I-Ik1EN.js";
4
4
  import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-BkNjkDCk.js";
5
5
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
@@ -1,3 +1,3 @@
1
1
  import { C as MigrationStep, D as defineMigration, E as buildMigrationPlan, O as defineMigrationSet, S as MigrationStateMap, T as MigrationWriteMode, _ as MigrationManifestEntry, a as MAX_STATUS_RUN_LIMIT, b as MigrationRunStatus, c as MigrationRunChunkArgs, d as MigrationAppliedState, f as MigrationDefinition, g as MigrationDriftIssue, h as MigrationDocContext, k as detectMigrationDrift, l as MigrationStatusArgs, m as MigrationDoc, o as MigrationCancelArgs, p as MigrationDirection, s as MigrationRunArgs, u as createMigrationHandlers, v as MigrationMigrateOne, w as MigrationTableName, x as MigrationSet, y as MigrationPlan } from "../../capabilities-Bxzoofl4.js";
2
- import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-DAqhUREe.js";
2
+ import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-CTblNxLo.js";
3
3
  export { MAX_STATUS_RUN_LIMIT, MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
@@ -6,7 +6,8 @@ type GetTokenOptions = {
6
6
  jwtCache?: {
7
7
  enabled: boolean;
8
8
  expirationToleranceSeconds?: number;
9
- isAuthError: (error: unknown) => boolean;
9
+ isAuthError: (error: unknown) => boolean; /** Current Unix time in seconds. Defaults to the system clock. */
10
+ now?: () => number | Promise<number>;
10
11
  };
11
12
  };
12
13
  //#endregion
@@ -32,14 +32,23 @@ const getToken = async (siteUrl, headers, opts) => {
32
32
  cookiePrefix: opts?.cookiePrefix
33
33
  });
34
34
  if (!token) return await fetchToken();
35
+ let claims;
35
36
  try {
36
- if (!isTokenExpired(jose.decodeJwt(token)?.exp, opts?.jwtCache?.expirationToleranceSeconds ?? 60)) return {
37
- isFresh: false,
38
- token
39
- };
37
+ claims = jose.decodeJwt(token);
40
38
  } catch (error) {
41
39
  console.error("Error decoding JWT", error);
40
+ return await fetchToken();
41
+ }
42
+ if (!claims.exp) return await fetchToken();
43
+ let now;
44
+ if (opts.jwtCache.now) {
45
+ now = await opts.jwtCache.now();
46
+ if (!Number.isFinite(now)) throw new RangeError("JWT cache now must return finite Unix time in seconds");
42
47
  }
48
+ if (!isTokenExpired(claims.exp, opts.jwtCache.expirationToleranceSeconds ?? 60, now)) return {
49
+ isFresh: false,
50
+ token
51
+ };
43
52
  return await fetchToken();
44
53
  };
45
54
 
@@ -111,29 +111,29 @@ declare const migrationStorageTables: {
111
111
  fieldName: "cursor";
112
112
  };
113
113
  };
114
- processed: ConvexNumberBuilderInitial<""> & {
115
- _: {
116
- notNull: true;
117
- };
118
- } & {
114
+ direction: ConvexTextBuilderInitial<""> & {
119
115
  _: {
120
116
  tableName: "migration_state";
121
117
  };
122
118
  } & {
123
119
  _: {
124
- fieldName: "processed";
120
+ fieldName: "direction";
125
121
  };
126
122
  };
127
- startedAt: ConvexNumberBuilderInitial<""> & {
123
+ migrationId: ConvexTextBuilderInitial<""> & {
124
+ _: {
125
+ notNull: true;
126
+ };
127
+ } & {
128
128
  _: {
129
129
  tableName: "migration_state";
130
130
  };
131
131
  } & {
132
132
  _: {
133
- fieldName: "startedAt";
133
+ fieldName: "migrationId";
134
134
  };
135
135
  };
136
- updatedAt: ConvexNumberBuilderInitial<""> & {
136
+ checksum: ConvexTextBuilderInitial<""> & {
137
137
  _: {
138
138
  notNull: true;
139
139
  };
@@ -143,28 +143,32 @@ declare const migrationStorageTables: {
143
143
  };
144
144
  } & {
145
145
  _: {
146
- fieldName: "updatedAt";
146
+ fieldName: "checksum";
147
147
  };
148
148
  };
149
- completedAt: ConvexNumberBuilderInitial<""> & {
149
+ applied: ConvexBooleanBuilderInitial<""> & {
150
+ _: {
151
+ notNull: true;
152
+ };
153
+ } & {
150
154
  _: {
151
155
  tableName: "migration_state";
152
156
  };
153
157
  } & {
154
158
  _: {
155
- fieldName: "completedAt";
159
+ fieldName: "applied";
156
160
  };
157
161
  };
158
- lastError: ConvexTextBuilderInitial<""> & {
162
+ runId: ConvexTextBuilderInitial<""> & {
159
163
  _: {
160
164
  tableName: "migration_state";
161
165
  };
162
166
  } & {
163
167
  _: {
164
- fieldName: "lastError";
168
+ fieldName: "runId";
165
169
  };
166
170
  };
167
- migrationId: ConvexTextBuilderInitial<""> & {
171
+ processed: ConvexNumberBuilderInitial<""> & {
168
172
  _: {
169
173
  notNull: true;
170
174
  };
@@ -174,23 +178,19 @@ declare const migrationStorageTables: {
174
178
  };
175
179
  } & {
176
180
  _: {
177
- fieldName: "migrationId";
181
+ fieldName: "processed";
178
182
  };
179
183
  };
180
- checksum: ConvexTextBuilderInitial<""> & {
181
- _: {
182
- notNull: true;
183
- };
184
- } & {
184
+ startedAt: ConvexNumberBuilderInitial<""> & {
185
185
  _: {
186
186
  tableName: "migration_state";
187
187
  };
188
188
  } & {
189
189
  _: {
190
- fieldName: "checksum";
190
+ fieldName: "startedAt";
191
191
  };
192
192
  };
193
- applied: ConvexBooleanBuilderInitial<""> & {
193
+ updatedAt: ConvexNumberBuilderInitial<""> & {
194
194
  _: {
195
195
  notNull: true;
196
196
  };
@@ -200,25 +200,25 @@ declare const migrationStorageTables: {
200
200
  };
201
201
  } & {
202
202
  _: {
203
- fieldName: "applied";
203
+ fieldName: "updatedAt";
204
204
  };
205
205
  };
206
- direction: ConvexTextBuilderInitial<""> & {
206
+ completedAt: ConvexNumberBuilderInitial<""> & {
207
207
  _: {
208
208
  tableName: "migration_state";
209
209
  };
210
210
  } & {
211
211
  _: {
212
- fieldName: "direction";
212
+ fieldName: "completedAt";
213
213
  };
214
214
  };
215
- runId: ConvexTextBuilderInitial<""> & {
215
+ lastError: ConvexTextBuilderInitial<""> & {
216
216
  _: {
217
217
  tableName: "migration_state";
218
218
  };
219
219
  } & {
220
220
  _: {
221
- fieldName: "runId";
221
+ fieldName: "lastError";
222
222
  };
223
223
  };
224
224
  writeMode: ConvexTextBuilderInitial<""> & {
@@ -256,7 +256,7 @@ declare const migrationStorageTables: {
256
256
  fieldName: "status";
257
257
  };
258
258
  };
259
- startedAt: ConvexNumberBuilderInitial<""> & {
259
+ direction: ConvexTextBuilderInitial<""> & {
260
260
  _: {
261
261
  notNull: true;
262
262
  };
@@ -266,10 +266,10 @@ declare const migrationStorageTables: {
266
266
  };
267
267
  } & {
268
268
  _: {
269
- fieldName: "startedAt";
269
+ fieldName: "direction";
270
270
  };
271
271
  };
272
- updatedAt: ConvexNumberBuilderInitial<""> & {
272
+ runId: ConvexTextBuilderInitial<""> & {
273
273
  _: {
274
274
  notNull: true;
275
275
  };
@@ -279,28 +279,23 @@ declare const migrationStorageTables: {
279
279
  };
280
280
  } & {
281
281
  _: {
282
- fieldName: "updatedAt";
282
+ fieldName: "runId";
283
283
  };
284
284
  };
285
- completedAt: ConvexNumberBuilderInitial<""> & {
285
+ startedAt: ConvexNumberBuilderInitial<""> & {
286
286
  _: {
287
- tableName: "migration_run";
287
+ notNull: true;
288
288
  };
289
289
  } & {
290
- _: {
291
- fieldName: "completedAt";
292
- };
293
- };
294
- lastError: ConvexTextBuilderInitial<""> & {
295
290
  _: {
296
291
  tableName: "migration_run";
297
292
  };
298
293
  } & {
299
294
  _: {
300
- fieldName: "lastError";
295
+ fieldName: "startedAt";
301
296
  };
302
297
  };
303
- direction: ConvexTextBuilderInitial<""> & {
298
+ updatedAt: ConvexNumberBuilderInitial<""> & {
304
299
  _: {
305
300
  notNull: true;
306
301
  };
@@ -310,20 +305,25 @@ declare const migrationStorageTables: {
310
305
  };
311
306
  } & {
312
307
  _: {
313
- fieldName: "direction";
308
+ fieldName: "updatedAt";
314
309
  };
315
310
  };
316
- runId: ConvexTextBuilderInitial<""> & {
311
+ completedAt: ConvexNumberBuilderInitial<""> & {
317
312
  _: {
318
- notNull: true;
313
+ tableName: "migration_run";
319
314
  };
320
315
  } & {
316
+ _: {
317
+ fieldName: "completedAt";
318
+ };
319
+ };
320
+ lastError: ConvexTextBuilderInitial<""> & {
321
321
  _: {
322
322
  tableName: "migration_run";
323
323
  };
324
324
  } & {
325
325
  _: {
326
- fieldName: "runId";
326
+ fieldName: "lastError";
327
327
  };
328
328
  };
329
329
  dryRun: ConvexBooleanBuilderInitial<""> & {
@@ -1011,7 +1011,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1011
1011
  readonly aggregate_bucket: ConvexTableWithColumns<{
1012
1012
  name: "aggregate_bucket";
1013
1013
  columns: {
1014
- indexName: ConvexTextBuilderInitial<""> & {
1014
+ count: ConvexNumberBuilderInitial<""> & {
1015
1015
  _: {
1016
1016
  notNull: true;
1017
1017
  };
@@ -1021,7 +1021,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1021
1021
  };
1022
1022
  } & {
1023
1023
  _: {
1024
- fieldName: "indexName";
1024
+ fieldName: "count";
1025
1025
  };
1026
1026
  };
1027
1027
  updatedAt: ConvexNumberBuilderInitial<""> & {
@@ -1037,7 +1037,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1037
1037
  fieldName: "updatedAt";
1038
1038
  };
1039
1039
  };
1040
- tableKey: ConvexTextBuilderInitial<""> & {
1040
+ indexName: ConvexTextBuilderInitial<""> & {
1041
1041
  _: {
1042
1042
  notNull: true;
1043
1043
  };
@@ -1047,10 +1047,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1047
1047
  };
1048
1048
  } & {
1049
1049
  _: {
1050
- fieldName: "tableKey";
1050
+ fieldName: "indexName";
1051
1051
  };
1052
1052
  };
1053
- count: ConvexNumberBuilderInitial<""> & {
1053
+ tableKey: ConvexTextBuilderInitial<""> & {
1054
1054
  _: {
1055
1055
  notNull: true;
1056
1056
  };
@@ -1060,7 +1060,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1060
1060
  };
1061
1061
  } & {
1062
1062
  _: {
1063
- fieldName: "count";
1063
+ fieldName: "tableKey";
1064
1064
  };
1065
1065
  };
1066
1066
  keyHash: ConvexTextBuilderInitial<""> & {
@@ -1149,7 +1149,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1149
1149
  fieldName: "kind";
1150
1150
  };
1151
1151
  };
1152
- indexName: ConvexTextBuilderInitial<""> & {
1152
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1153
1153
  _: {
1154
1154
  notNull: true;
1155
1155
  };
@@ -1159,10 +1159,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1159
1159
  };
1160
1160
  } & {
1161
1161
  _: {
1162
- fieldName: "indexName";
1162
+ fieldName: "updatedAt";
1163
1163
  };
1164
1164
  };
1165
- updatedAt: ConvexNumberBuilderInitial<""> & {
1165
+ indexName: ConvexTextBuilderInitial<""> & {
1166
1166
  _: {
1167
1167
  notNull: true;
1168
1168
  };
@@ -1172,7 +1172,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1172
1172
  };
1173
1173
  } & {
1174
1174
  _: {
1175
- fieldName: "updatedAt";
1175
+ fieldName: "indexName";
1176
1176
  };
1177
1177
  };
1178
1178
  tableKey: ConvexTextBuilderInitial<""> & {
@@ -1326,7 +1326,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1326
1326
  readonly aggregate_extrema: ConvexTableWithColumns<{
1327
1327
  name: "aggregate_extrema";
1328
1328
  columns: {
1329
- indexName: ConvexTextBuilderInitial<""> & {
1329
+ count: ConvexNumberBuilderInitial<""> & {
1330
1330
  _: {
1331
1331
  notNull: true;
1332
1332
  };
@@ -1336,10 +1336,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1336
1336
  };
1337
1337
  } & {
1338
1338
  _: {
1339
- fieldName: "indexName";
1339
+ fieldName: "count";
1340
1340
  };
1341
1341
  };
1342
- updatedAt: ConvexNumberBuilderInitial<""> & {
1342
+ value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
1343
+ _: {
1344
+ $type: convex_values0.Value;
1345
+ };
1346
+ } & {
1343
1347
  _: {
1344
1348
  notNull: true;
1345
1349
  };
@@ -1349,10 +1353,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1349
1353
  };
1350
1354
  } & {
1351
1355
  _: {
1352
- fieldName: "updatedAt";
1356
+ fieldName: "value";
1353
1357
  };
1354
1358
  };
1355
- tableKey: ConvexTextBuilderInitial<""> & {
1359
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1356
1360
  _: {
1357
1361
  notNull: true;
1358
1362
  };
@@ -1362,10 +1366,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1362
1366
  };
1363
1367
  } & {
1364
1368
  _: {
1365
- fieldName: "tableKey";
1369
+ fieldName: "updatedAt";
1366
1370
  };
1367
1371
  };
1368
- count: ConvexNumberBuilderInitial<""> & {
1372
+ indexName: ConvexTextBuilderInitial<""> & {
1369
1373
  _: {
1370
1374
  notNull: true;
1371
1375
  };
@@ -1375,14 +1379,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1375
1379
  };
1376
1380
  } & {
1377
1381
  _: {
1378
- fieldName: "count";
1382
+ fieldName: "indexName";
1379
1383
  };
1380
1384
  };
1381
- value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
1382
- _: {
1383
- $type: convex_values0.Value;
1384
- };
1385
- } & {
1385
+ tableKey: ConvexTextBuilderInitial<""> & {
1386
1386
  _: {
1387
1387
  notNull: true;
1388
1388
  };
@@ -1392,7 +1392,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1392
1392
  };
1393
1393
  } & {
1394
1394
  _: {
1395
- fieldName: "value";
1395
+ fieldName: "tableKey";
1396
1396
  };
1397
1397
  };
1398
1398
  keyHash: ConvexTextBuilderInitial<""> & {
@@ -1596,6 +1596,15 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1596
1596
  fieldName: "status";
1597
1597
  };
1598
1598
  };
1599
+ cursor: ConvexTextBuilderInitial<""> & {
1600
+ _: {
1601
+ tableName: "aggregate_state";
1602
+ };
1603
+ } & {
1604
+ _: {
1605
+ fieldName: "cursor";
1606
+ };
1607
+ };
1599
1608
  kind: ConvexTextBuilderInitial<""> & {
1600
1609
  _: {
1601
1610
  notNull: true;
@@ -1609,7 +1618,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1609
1618
  fieldName: "kind";
1610
1619
  };
1611
1620
  };
1612
- indexName: ConvexTextBuilderInitial<""> & {
1621
+ processed: ConvexNumberBuilderInitial<""> & {
1613
1622
  _: {
1614
1623
  notNull: true;
1615
1624
  };
@@ -1619,10 +1628,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1619
1628
  };
1620
1629
  } & {
1621
1630
  _: {
1622
- fieldName: "indexName";
1631
+ fieldName: "processed";
1623
1632
  };
1624
1633
  };
1625
- keyDefinitionHash: ConvexTextBuilderInitial<""> & {
1634
+ startedAt: ConvexNumberBuilderInitial<""> & {
1626
1635
  _: {
1627
1636
  notNull: true;
1628
1637
  };
@@ -1632,10 +1641,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1632
1641
  };
1633
1642
  } & {
1634
1643
  _: {
1635
- fieldName: "keyDefinitionHash";
1644
+ fieldName: "startedAt";
1636
1645
  };
1637
1646
  };
1638
- metricDefinitionHash: ConvexTextBuilderInitial<""> & {
1647
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1639
1648
  _: {
1640
1649
  notNull: true;
1641
1650
  };
@@ -1645,32 +1654,28 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1645
1654
  };
1646
1655
  } & {
1647
1656
  _: {
1648
- fieldName: "metricDefinitionHash";
1657
+ fieldName: "updatedAt";
1649
1658
  };
1650
1659
  };
1651
- cursor: ConvexTextBuilderInitial<""> & {
1660
+ completedAt: ConvexNumberBuilderInitial<""> & {
1652
1661
  _: {
1653
1662
  tableName: "aggregate_state";
1654
1663
  };
1655
1664
  } & {
1656
1665
  _: {
1657
- fieldName: "cursor";
1666
+ fieldName: "completedAt";
1658
1667
  };
1659
1668
  };
1660
- processed: ConvexNumberBuilderInitial<""> & {
1661
- _: {
1662
- notNull: true;
1663
- };
1664
- } & {
1669
+ lastError: ConvexTextBuilderInitial<""> & {
1665
1670
  _: {
1666
1671
  tableName: "aggregate_state";
1667
1672
  };
1668
1673
  } & {
1669
1674
  _: {
1670
- fieldName: "processed";
1675
+ fieldName: "lastError";
1671
1676
  };
1672
1677
  };
1673
- startedAt: ConvexNumberBuilderInitial<""> & {
1678
+ indexName: ConvexTextBuilderInitial<""> & {
1674
1679
  _: {
1675
1680
  notNull: true;
1676
1681
  };
@@ -1680,10 +1685,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1680
1685
  };
1681
1686
  } & {
1682
1687
  _: {
1683
- fieldName: "startedAt";
1688
+ fieldName: "indexName";
1684
1689
  };
1685
1690
  };
1686
- updatedAt: ConvexNumberBuilderInitial<""> & {
1691
+ keyDefinitionHash: ConvexTextBuilderInitial<""> & {
1687
1692
  _: {
1688
1693
  notNull: true;
1689
1694
  };
@@ -1693,25 +1698,20 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1693
1698
  };
1694
1699
  } & {
1695
1700
  _: {
1696
- fieldName: "updatedAt";
1701
+ fieldName: "keyDefinitionHash";
1697
1702
  };
1698
1703
  };
1699
- completedAt: ConvexNumberBuilderInitial<""> & {
1704
+ metricDefinitionHash: ConvexTextBuilderInitial<""> & {
1700
1705
  _: {
1701
- tableName: "aggregate_state";
1706
+ notNull: true;
1702
1707
  };
1703
1708
  } & {
1704
- _: {
1705
- fieldName: "completedAt";
1706
- };
1707
- };
1708
- lastError: ConvexTextBuilderInitial<""> & {
1709
1709
  _: {
1710
1710
  tableName: "aggregate_state";
1711
1711
  };
1712
1712
  } & {
1713
1713
  _: {
1714
- fieldName: "lastError";
1714
+ fieldName: "metricDefinitionHash";
1715
1715
  };
1716
1716
  };
1717
1717
  tableKey: ConvexTextBuilderInitial<""> & {
@@ -1760,29 +1760,29 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1760
1760
  fieldName: "cursor";
1761
1761
  };
1762
1762
  };
1763
- processed: ConvexNumberBuilderInitial<""> & {
1764
- _: {
1765
- notNull: true;
1766
- };
1767
- } & {
1763
+ direction: ConvexTextBuilderInitial<""> & {
1768
1764
  _: {
1769
1765
  tableName: "migration_state";
1770
1766
  };
1771
1767
  } & {
1772
1768
  _: {
1773
- fieldName: "processed";
1769
+ fieldName: "direction";
1774
1770
  };
1775
1771
  };
1776
- startedAt: ConvexNumberBuilderInitial<""> & {
1772
+ migrationId: ConvexTextBuilderInitial<""> & {
1773
+ _: {
1774
+ notNull: true;
1775
+ };
1776
+ } & {
1777
1777
  _: {
1778
1778
  tableName: "migration_state";
1779
1779
  };
1780
1780
  } & {
1781
1781
  _: {
1782
- fieldName: "startedAt";
1782
+ fieldName: "migrationId";
1783
1783
  };
1784
1784
  };
1785
- updatedAt: ConvexNumberBuilderInitial<""> & {
1785
+ checksum: ConvexTextBuilderInitial<""> & {
1786
1786
  _: {
1787
1787
  notNull: true;
1788
1788
  };
@@ -1792,28 +1792,32 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1792
1792
  };
1793
1793
  } & {
1794
1794
  _: {
1795
- fieldName: "updatedAt";
1795
+ fieldName: "checksum";
1796
1796
  };
1797
1797
  };
1798
- completedAt: ConvexNumberBuilderInitial<""> & {
1798
+ applied: ConvexBooleanBuilderInitial<""> & {
1799
+ _: {
1800
+ notNull: true;
1801
+ };
1802
+ } & {
1799
1803
  _: {
1800
1804
  tableName: "migration_state";
1801
1805
  };
1802
1806
  } & {
1803
1807
  _: {
1804
- fieldName: "completedAt";
1808
+ fieldName: "applied";
1805
1809
  };
1806
1810
  };
1807
- lastError: ConvexTextBuilderInitial<""> & {
1811
+ runId: ConvexTextBuilderInitial<""> & {
1808
1812
  _: {
1809
1813
  tableName: "migration_state";
1810
1814
  };
1811
1815
  } & {
1812
1816
  _: {
1813
- fieldName: "lastError";
1817
+ fieldName: "runId";
1814
1818
  };
1815
1819
  };
1816
- migrationId: ConvexTextBuilderInitial<""> & {
1820
+ processed: ConvexNumberBuilderInitial<""> & {
1817
1821
  _: {
1818
1822
  notNull: true;
1819
1823
  };
@@ -1823,23 +1827,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1823
1827
  };
1824
1828
  } & {
1825
1829
  _: {
1826
- fieldName: "migrationId";
1830
+ fieldName: "processed";
1827
1831
  };
1828
1832
  };
1829
- checksum: ConvexTextBuilderInitial<""> & {
1830
- _: {
1831
- notNull: true;
1832
- };
1833
- } & {
1833
+ startedAt: ConvexNumberBuilderInitial<""> & {
1834
1834
  _: {
1835
1835
  tableName: "migration_state";
1836
1836
  };
1837
1837
  } & {
1838
1838
  _: {
1839
- fieldName: "checksum";
1839
+ fieldName: "startedAt";
1840
1840
  };
1841
1841
  };
1842
- applied: ConvexBooleanBuilderInitial<""> & {
1842
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1843
1843
  _: {
1844
1844
  notNull: true;
1845
1845
  };
@@ -1849,25 +1849,25 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1849
1849
  };
1850
1850
  } & {
1851
1851
  _: {
1852
- fieldName: "applied";
1852
+ fieldName: "updatedAt";
1853
1853
  };
1854
1854
  };
1855
- direction: ConvexTextBuilderInitial<""> & {
1855
+ completedAt: ConvexNumberBuilderInitial<""> & {
1856
1856
  _: {
1857
1857
  tableName: "migration_state";
1858
1858
  };
1859
1859
  } & {
1860
1860
  _: {
1861
- fieldName: "direction";
1861
+ fieldName: "completedAt";
1862
1862
  };
1863
1863
  };
1864
- runId: ConvexTextBuilderInitial<""> & {
1864
+ lastError: ConvexTextBuilderInitial<""> & {
1865
1865
  _: {
1866
1866
  tableName: "migration_state";
1867
1867
  };
1868
1868
  } & {
1869
1869
  _: {
1870
- fieldName: "runId";
1870
+ fieldName: "lastError";
1871
1871
  };
1872
1872
  };
1873
1873
  writeMode: ConvexTextBuilderInitial<""> & {
@@ -1905,7 +1905,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1905
1905
  fieldName: "status";
1906
1906
  };
1907
1907
  };
1908
- startedAt: ConvexNumberBuilderInitial<""> & {
1908
+ direction: ConvexTextBuilderInitial<""> & {
1909
1909
  _: {
1910
1910
  notNull: true;
1911
1911
  };
@@ -1915,10 +1915,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1915
1915
  };
1916
1916
  } & {
1917
1917
  _: {
1918
- fieldName: "startedAt";
1918
+ fieldName: "direction";
1919
1919
  };
1920
1920
  };
1921
- updatedAt: ConvexNumberBuilderInitial<""> & {
1921
+ runId: ConvexTextBuilderInitial<""> & {
1922
1922
  _: {
1923
1923
  notNull: true;
1924
1924
  };
@@ -1928,28 +1928,23 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1928
1928
  };
1929
1929
  } & {
1930
1930
  _: {
1931
- fieldName: "updatedAt";
1931
+ fieldName: "runId";
1932
1932
  };
1933
1933
  };
1934
- completedAt: ConvexNumberBuilderInitial<""> & {
1934
+ startedAt: ConvexNumberBuilderInitial<""> & {
1935
1935
  _: {
1936
- tableName: "migration_run";
1936
+ notNull: true;
1937
1937
  };
1938
1938
  } & {
1939
- _: {
1940
- fieldName: "completedAt";
1941
- };
1942
- };
1943
- lastError: ConvexTextBuilderInitial<""> & {
1944
1939
  _: {
1945
1940
  tableName: "migration_run";
1946
1941
  };
1947
1942
  } & {
1948
1943
  _: {
1949
- fieldName: "lastError";
1944
+ fieldName: "startedAt";
1950
1945
  };
1951
1946
  };
1952
- direction: ConvexTextBuilderInitial<""> & {
1947
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1953
1948
  _: {
1954
1949
  notNull: true;
1955
1950
  };
@@ -1959,20 +1954,25 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1959
1954
  };
1960
1955
  } & {
1961
1956
  _: {
1962
- fieldName: "direction";
1957
+ fieldName: "updatedAt";
1963
1958
  };
1964
1959
  };
1965
- runId: ConvexTextBuilderInitial<""> & {
1960
+ completedAt: ConvexNumberBuilderInitial<""> & {
1966
1961
  _: {
1967
- notNull: true;
1962
+ tableName: "migration_run";
1968
1963
  };
1969
1964
  } & {
1965
+ _: {
1966
+ fieldName: "completedAt";
1967
+ };
1968
+ };
1969
+ lastError: ConvexTextBuilderInitial<""> & {
1970
1970
  _: {
1971
1971
  tableName: "migration_run";
1972
1972
  };
1973
1973
  } & {
1974
1974
  _: {
1975
- fieldName: "runId";
1975
+ fieldName: "lastError";
1976
1976
  };
1977
1977
  };
1978
1978
  dryRun: ConvexBooleanBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.33.7",
3
+ "version": "0.33.8",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -539,7 +539,11 @@ export const { createContext, createCaller, handler } = convexBetterAuth({
539
539
  | `createCaller` | Server-side caller factory |
540
540
  | `handler` | Next.js API route handler (`export const { GET, POST, OPTIONS } = handler;`) |
541
541
 
542
- Options: `api`, `convexSiteUrl`, `auth.jwtCache` (default true), `auth.isUnauthorized`.
542
+ Options: `api`, `convexSiteUrl`, `auth.jwtCache` (boolean or `{ now }`, default true),
543
+ `auth.expirationToleranceSeconds` (default 60), `auth.isUnauthorized`.
544
+ `now` returns finite Unix seconds or a promise of seconds. For Next partial
545
+ prefetching and request-time versus private-cache clocks, follow
546
+ [Next setup](../setup/next.md#8a4-jwt-cache-and-partial-prefetching).
543
547
 
544
548
  ### Client Provider with Auth
545
549
 
@@ -98,7 +98,54 @@ export function HydrateClient({ children }: { children: React.ReactNode }) {
98
98
  }
99
99
  ```
100
100
 
101
- ### 8.A.4 Pass server token to provider
101
+ ### 8.A.4 JWT cache and partial prefetching
102
+
103
+ With Next 16 `cacheComponents` and `partialPrefetching`, the default JWT expiry
104
+ clock can trigger a Blocking Route error even after `await headers()`. The
105
+ app owns clock timing. For request-time contexts, configure the server factory:
106
+
107
+ ```ts
108
+ import { connection } from 'next/server';
109
+
110
+ export const { createContext, createCaller, handler } = convexBetterAuth({
111
+ api,
112
+ convexSiteUrl: process.env.NEXT_PUBLIC_CONVEX_SITE_URL!,
113
+ auth: {
114
+ jwtCache: {
115
+ now: async () => {
116
+ await connection();
117
+ return Math.floor(Date.now() / 1000);
118
+ },
119
+ },
120
+ },
121
+ });
122
+ ```
123
+
124
+ `auth.jwtCache` accepts a boolean or `{ now?: () => number | Promise<number> }`.
125
+ The clock returns finite **Unix seconds**, not milliseconds. The reader awaits
126
+ it only for a decoded cached JWT with an expiry. Disabled caching, forced
127
+ refresh, missing/malformed cookies, and absent expiry bypass the hook.
128
+ `auth.expirationToleranceSeconds` remains a sibling option (default 60).
129
+ Clock throws/rejections propagate unchanged; `NaN` and infinities are rejected.
130
+
131
+ Keep `await headers()` in the RSC context creator. Put request-time token reads
132
+ under `Suspense`, including a provider or route gate that awaits `caller.getToken()`.
133
+ For `'use cache: private'`, use a separate factory with the default or a sync
134
+ clock; **never call `connection()` inside private cache**. A private token helper
135
+ can use `cacheLife({ stale: 30 })`, read headers, create that context, and return
136
+ `context.token`. A token-blocking layout must defer its token-dependent subtree
137
+ with `Suspense`, including when awaiting a private-cache helper. Private caching
138
+ allows the clock read but does not make runtime auth data static.
139
+
140
+ `auth: { jwtCache: false }` avoids the cookie expiry clock but fetches a token
141
+ on every context creation. Kitcn does not import Next, detect render stages, or
142
+ suppress render aborts. An app that runs a `connection()` clock through TanStack
143
+ queries owns abort handling because recording a query failure can also read
144
+ `Date.now()`. Do not suppress ordinary auth failures.
145
+
146
+ Full examples: [Next.js JWT cache guidance](https://kitcn.dev/docs/nextjs#jwt-cache-and-partial-prefetching).
147
+
148
+ ### 8.A.5 Pass server token to provider
102
149
 
103
150
  ```tsx
104
151
  // app/(app)/layout.tsx