kitcn 0.28.0 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # kitcn
2
2
 
3
+ ## 0.28.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#420](https://github.com/udecode/kitcn/pull/420) [`73741ed`](https://github.com/udecode/kitcn/commit/73741ed08779d539c9f186db366e326b138dbd36) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
8
+
9
+ - Fix `insert()` re-reading the same parent row once per inserted row. Rows of one statement that share a foreign key now cost one existence check instead of one per row.
10
+ - Fix the aggregate write barrier re-scanning the `CLEARING` index-state range once per written row. A multi-row write now checks it once per transaction, and a backfill that starts clearing an index still blocks the writes that follow it.
11
+ - Fix a relation `where` re-reading the same related document once per scanned row. Filtering by a relation now reads each distinct related document once per query instead of once per candidate row.
12
+
3
13
  ## 0.28.0
4
14
 
5
15
  ### Minor Changes
@@ -1,5 +1,5 @@
1
- import { Bn as ConvexTextBuilderInitial, Xt as ConvexTableWithColumns } from "../capabilities-DkfnnNp7.js";
2
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-CETRjurp.js";
1
+ import { Bn as ConvexTextBuilderInitial, Xt as ConvexTableWithColumns } from "../capabilities-BAiI8avr.js";
2
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-DdAw9rNV.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 GenericAuthTriggers, S as GenericAuthTriggerHandlers, b as GenericAuthDefinition, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as BetterAuthOptionsWithoutDatabase, w as defineAuth, x as GenericAuthTriggerChange, y as GenericAuthBeforeResult } from "../../generated-contract-disabled-Btfy2opW.js";
1
+ import { C as GenericAuthTriggers, S as GenericAuthTriggerHandlers, b as GenericAuthDefinition, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as BetterAuthOptionsWithoutDatabase, w as defineAuth, x as GenericAuthTriggerChange, y as GenericAuthBeforeResult } from "../../generated-contract-disabled-BBCcpNyF.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-DJONf8X5.js";
2
2
  import { t as GetAuth } from "../types-Bf3XQex5.js";
3
3
  import { t as GenericCtx } from "../context-utils-DwZ3Cam1.js";
4
- import { C as GenericAuthTriggers, S as GenericAuthTriggerHandlers, _ as updateOneHandler, a as AuthFunctions, b as GenericAuthDefinition, c as consumeOneHandler, d as deleteManyHandler, f as deleteOneHandler, g as updateManyHandler, h as incrementOneHandler, i as getGeneratedAuthDisabledReason, l as createApi, m as findOneHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findManyHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createHandler, v as BetterAuthOptionsWithoutDatabase, w as defineAuth, x as GenericAuthTriggerChange, y as GenericAuthBeforeResult } from "../generated-contract-disabled-Btfy2opW.js";
4
+ import { C as GenericAuthTriggers, S as GenericAuthTriggerHandlers, _ as updateOneHandler, a as AuthFunctions, b as GenericAuthDefinition, c as consumeOneHandler, d as deleteManyHandler, f as deleteOneHandler, g as updateManyHandler, h as incrementOneHandler, i as getGeneratedAuthDisabledReason, l as createApi, m as findOneHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findManyHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createHandler, v as BetterAuthOptionsWithoutDatabase, w as defineAuth, x as GenericAuthTriggerChange, y as GenericAuthBeforeResult } from "../generated-contract-disabled-BBCcpNyF.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";
@@ -111,24 +111,24 @@ declare const adapterWhereValidator: convex_values0.VObject<{
111
111
  mode?: "sensitive" | "insensitive" | undefined;
112
112
  connector?: "AND" | "OR" | undefined;
113
113
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
114
- field: string;
115
114
  value: string | number | boolean | string[] | number[] | null;
115
+ field: string;
116
116
  }, {
117
117
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
118
118
  field: convex_values0.VString<string, "required">;
119
119
  mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
120
120
  operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
121
121
  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>;
122
- }, "required", "mode" | "connector" | "field" | "operator" | "value">;
122
+ }, "required", "mode" | "value" | "connector" | "field" | "operator">;
123
123
  declare const adapterArgsValidator: convex_values0.VObject<{
124
- limit?: number | undefined;
125
124
  where?: {
126
125
  mode?: "sensitive" | "insensitive" | undefined;
127
126
  connector?: "AND" | "OR" | undefined;
128
127
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
129
- field: string;
130
128
  value: string | number | boolean | string[] | number[] | null;
129
+ field: string;
131
130
  }[] | undefined;
131
+ limit?: number | undefined;
132
132
  offset?: number | undefined;
133
133
  select?: string[] | undefined;
134
134
  sortBy?: {
@@ -152,22 +152,22 @@ declare const adapterArgsValidator: convex_values0.VObject<{
152
152
  mode?: "sensitive" | "insensitive" | undefined;
153
153
  connector?: "AND" | "OR" | undefined;
154
154
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
155
- field: string;
156
155
  value: string | number | boolean | string[] | number[] | null;
156
+ field: string;
157
157
  }[] | undefined, convex_values0.VObject<{
158
158
  mode?: "sensitive" | "insensitive" | undefined;
159
159
  connector?: "AND" | "OR" | undefined;
160
160
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
161
- field: string;
162
161
  value: string | number | boolean | string[] | number[] | null;
162
+ field: string;
163
163
  }, {
164
164
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
165
165
  field: convex_values0.VString<string, "required">;
166
166
  mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
167
167
  operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
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
- }, "required", "mode" | "connector" | "field" | "operator" | "value">, "optional">;
170
- }, "required", "limit" | "model" | "where" | "offset" | "select" | "sortBy" | "sortBy.field" | "sortBy.direction">;
169
+ }, "required", "mode" | "value" | "connector" | "field" | "operator">, "optional">;
170
+ }, "required", "model" | "where" | "limit" | "offset" | "select" | "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;
@@ -2892,6 +2892,22 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
2892
2892
  * hands it to the next run rather than re-probing.
2893
2893
  */
2894
2894
  private _aggregateIndexReadinessByKey;
2895
+ /**
2896
+ * Documents resolved by id during one execution, keyed on the normalized id.
2897
+ *
2898
+ * A relation `where` never compiles into the index plan, so it runs as a
2899
+ * post-fetch membership predicate over a residual stream — one row at a time.
2900
+ * Every de-duplication map inside the relation loaders is scoped to the batch
2901
+ * it is handed, and a batch of one makes all of them no-ops, so a page whose
2902
+ * rows share two parents re-read those two documents once per scanned row.
2903
+ *
2904
+ * Scoped to one execution, like `_rlsPolicyResolution`: `_executionClaimed`
2905
+ * diverts later executions to a fresh instance, and an execution reads
2906
+ * without writing, so a hit is always the document the caller would have read
2907
+ * for itself. It must not be handed to the next run by `_forExecution` — an
2908
+ * intervening write would make it stale.
2909
+ */
2910
+ private readonly _documentByNormalizedId;
2895
2911
  constructor(schema: TSchema, tableConfig: TTableConfig, edgeMetadata: EdgeMetadata[], db: GenericDatabaseReader<any>, config: DBQueryConfig<'one' | 'many', boolean, TSchema, TTableConfig>, mode: 'many' | 'first' | 'firstOrThrow' | 'count' | 'aggregate' | 'groupBy', _allEdges?: EdgeMetadata[] | undefined, // M6.5 Phase 2: All edges for nested loading
2896
2912
  rls?: RlsContext | undefined, relationLoading?: {
2897
2913
  concurrency?: number;
@@ -183,8 +183,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
183
183
  where?: {
184
184
  connector?: "AND" | "OR" | undefined;
185
185
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
186
- field: string;
187
186
  value: string | number | boolean | string[] | number[] | null;
187
+ field: string;
188
188
  }[] | undefined;
189
189
  model: string;
190
190
  } | {
@@ -211,8 +211,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
211
211
  where?: {
212
212
  connector?: "AND" | "OR" | undefined;
213
213
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
214
- field: string;
215
214
  value: string | number | boolean | string[] | number[] | null;
215
+ field: string;
216
216
  }[] | undefined;
217
217
  model: string;
218
218
  } | {
@@ -240,8 +240,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
240
240
  where?: {
241
241
  connector?: "AND" | "OR" | undefined;
242
242
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
243
- field: string;
244
243
  value: string | number | boolean | string[] | number[] | null;
244
+ field: string;
245
245
  }[] | undefined;
246
246
  model: string;
247
247
  } | {
@@ -250,15 +250,15 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
250
250
  };
251
251
  }, Promise<Record<string, unknown> | undefined>>;
252
252
  findMany: convex_server0.RegisteredQuery<"internal", {
253
- limit?: number | undefined;
254
253
  join?: any;
255
254
  where?: {
256
255
  mode?: "sensitive" | "insensitive" | undefined;
257
256
  connector?: "AND" | "OR" | undefined;
258
257
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
259
- field: string;
260
258
  value: string | number | boolean | string[] | number[] | null;
259
+ field: string;
261
260
  }[] | undefined;
261
+ limit?: number | undefined;
262
262
  offset?: number | undefined;
263
263
  sortBy?: {
264
264
  field: string;
@@ -280,8 +280,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
280
280
  mode?: "sensitive" | "insensitive" | undefined;
281
281
  connector?: "AND" | "OR" | undefined;
282
282
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
283
- field: string;
284
283
  value: string | number | boolean | string[] | number[] | null;
284
+ field: string;
285
285
  }[] | undefined;
286
286
  select?: string[] | undefined;
287
287
  model: string;
@@ -289,14 +289,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
289
289
  getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
290
290
  incrementOne: convex_server0.RegisteredMutation<"internal", {
291
291
  input: {
292
- set?: Record<string, any> | undefined;
293
292
  where?: {
294
293
  mode?: "sensitive" | "insensitive" | undefined;
295
294
  connector?: "AND" | "OR" | undefined;
296
295
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
297
- field: string;
298
296
  value: string | number | boolean | string[] | number[] | null;
297
+ field: string;
299
298
  }[] | undefined;
299
+ set?: Record<string, any> | undefined;
300
300
  model: string;
301
301
  increment: Record<string, number>;
302
302
  };
@@ -307,8 +307,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
307
307
  where?: {
308
308
  connector?: "AND" | "OR" | undefined;
309
309
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
310
- field: string;
311
310
  value: string | number | boolean | string[] | number[] | null;
311
+ field: string;
312
312
  }[] | undefined;
313
313
  model: string;
314
314
  update: {
@@ -342,8 +342,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
342
342
  where?: {
343
343
  connector?: "AND" | "OR" | undefined;
344
344
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
345
- field: string;
346
345
  value: string | number | boolean | string[] | number[] | null;
346
+ field: string;
347
347
  }[] | undefined;
348
348
  model: string;
349
349
  update: {
@@ -1,4 +1,4 @@
1
- import { $ as RankOrderField, G as CountBackfillKickoffArgs, J as AggregateQueryPlan, K as CountBackfillMode, Q as RankIndexDefinition, W as CountBackfillChunkArgs, X as AggregateIndexDefinition, Y as CountQueryPlan, Z as CountIndexDefinition, q as CountBackfillStatusArgs, r as OrmCapability } from "../../capabilities-DkfnnNp7.js";
1
+ import { $ as RankOrderField, G as CountBackfillKickoffArgs, J as AggregateQueryPlan, K as CountBackfillMode, Q as RankIndexDefinition, W as CountBackfillChunkArgs, X as AggregateIndexDefinition, Y as CountQueryPlan, Z as CountIndexDefinition, q as CountBackfillStatusArgs, r as OrmCapability } from "../../capabilities-BAiI8avr.js";
2
2
 
3
3
  //#region src/orm/aggregate-index/capability.d.ts
4
4
  /**
@@ -1,7 +1,76 @@
1
1
  import { t as DirectAggregate } from "../../runtime-CcOvOf4K.js";
2
2
  import { a as Columns } from "../../table-CX2lnX7e.js";
3
- import { Et as usesSystemCreatedAtAlias, Tt as PUBLIC_CREATED_AT_FIELD, Z as normalizeTemporalComparableValue, a as AGGREGATE_STATE_TABLE, c as getAggregateIndexDefinitions, d as COUNT_ERROR, i as AGGREGATE_RANK_TREE_TABLE, l as getRankIndexDefinitions, m as createError, mt as mapWithConcurrency, n as AGGREGATE_EXTREMA_TABLE, r as AGGREGATE_MEMBER_TABLE, s as rankAggregateName, t as AGGREGATE_BUCKET_TABLE, u as AGGREGATE_ERROR, wt as INTERNAL_CREATION_TIME_FIELD } from "../../schema-D95Z3Kss.js";
3
+ import { Dt as usesSystemCreatedAtAlias, Et as PUBLIC_CREATED_AT_FIELD, Q as normalizeTemporalComparableValue, Tt as INTERNAL_CREATION_TIME_FIELD, a as AGGREGATE_STATE_TABLE, c as getAggregateIndexDefinitions, d as COUNT_ERROR, ht as mapWithConcurrency, i as AGGREGATE_RANK_TREE_TABLE, l as getRankIndexDefinitions, m as createError, n as AGGREGATE_EXTREMA_TABLE, r as AGGREGATE_MEMBER_TABLE, s as rankAggregateName, t as AGGREGATE_BUCKET_TABLE, u as AGGREGATE_ERROR } from "../../schema-CzdjX7nx.js";
4
4
 
5
+ //#region src/orm/transaction-cache.ts
6
+ /**
7
+ * Per-transaction memo storage for the ORM.
8
+ *
9
+ * The ORM already has isolate-, execution-, statement- and row-scoped memos.
10
+ * The lifetime it lacked is the one a hook needs: `prependWriteBarrier` is
11
+ * built inside `createOrmDbLifecycle`, which `createOrm` runs at module scope,
12
+ * so a flag in that closure lives as long as the isolate and would leak an
13
+ * answer from one transaction into the next.
14
+ *
15
+ * Deliberately dependency-free, for the same reason as `write-fanout`:
16
+ * `aggregate-index/runtime` is contractually unreachable from `orm/index`
17
+ * (`import-graph.test.ts`), so importing `lifecycle` here to read one symbol
18
+ * would drag the trigger runtime into the aggregate entry's bundle.
19
+ * `Symbol.for` is registry-based, so re-declaring the key resolves to the same
20
+ * symbol `lifecycle` installs.
21
+ */
22
+ const ORMLIFECYCLE_INNER_DB = Symbol.for("kitcn:OrmLifecycleInnerDB");
23
+ /**
24
+ * The object whose identity stands in for "this transaction".
25
+ *
26
+ * Convex builds `ctx.db` fresh on every UDF invocation, so it can never be
27
+ * shared by two transactions. `getOrmLifecycleInnerDb` cannot be used on its
28
+ * own: the lifecycle refuses to wrap readers and returns a no-op wrapper for
29
+ * schemas with no triggers and no aggregate indexes, so the inner-db symbol is
30
+ * absent for every query and for most mutations. Resolving through it when it
31
+ * is there, and falling back to the db itself when it is not, converges on the
32
+ * same raw writer from the main scope, `skipRules`, `withoutTriggers` and the
33
+ * scheduled workers.
34
+ *
35
+ * A nested `ctx.runMutation` shares the transaction but gets its own `ctx.db`,
36
+ * so it starts a fresh memo. That direction only costs extra reads.
37
+ */
38
+ const resolveTransactionAnchor = (db) => {
39
+ if (typeof db !== "object" || db === null) return;
40
+ const inner = db[ORMLIFECYCLE_INNER_DB];
41
+ return typeof inner === "object" && inner !== null ? inner : db;
42
+ };
43
+ /**
44
+ * One memo namespace with transaction lifetime.
45
+ *
46
+ * The store is a `WeakMap` keyed on the anchor rather than a slot on the db,
47
+ * because `createDatabase` promises not to mutate the `ctx.db` it was handed.
48
+ * Entries die with the transaction's db object.
49
+ *
50
+ * Callers own staleness: only memoize a fact that nothing inside the
51
+ * transaction can invalidate.
52
+ */
53
+ const createOrmTransactionMemo = () => {
54
+ const byTransaction = /* @__PURE__ */ new WeakMap();
55
+ return {
56
+ get(db, key) {
57
+ const anchor = resolveTransactionAnchor(db);
58
+ return anchor ? byTransaction.get(anchor)?.get(key) : void 0;
59
+ },
60
+ set(db, key, value) {
61
+ const anchor = resolveTransactionAnchor(db);
62
+ if (!anchor) return;
63
+ const existing = byTransaction.get(anchor);
64
+ if (existing) {
65
+ existing.set(key, value);
66
+ return;
67
+ }
68
+ byTransaction.set(anchor, new Map([[key, value]]));
69
+ }
70
+ };
71
+ };
72
+
73
+ //#endregion
5
74
  //#region src/orm/aggregate-index/runtime.ts
6
75
  const UNDEFINED_SENTINEL = "__kitcnUndefined";
7
76
  const FLOAT64_SIGN_BIT = 1n << 63n;
@@ -1247,8 +1316,36 @@ const getCountState = async (db, tableName, indexName, kind = AGGREGATE_STATE_KI
1247
1316
  tableName: tableKey
1248
1317
  };
1249
1318
  };
1319
+ /**
1320
+ * Bumped by every `setCountState`, which is the only writer that can move a
1321
+ * state row into CLEARING.
1322
+ *
1323
+ * Isolate-scoped mutable state is exactly what the write barrier must not rely
1324
+ * on, so this counter only ever invalidates: a bump can turn a cache hit into a
1325
+ * re-read, never a re-read into a hit. That direction stays safe when a
1326
+ * mutation reaches the backfill through `ctx.runMutation`, whose nested
1327
+ * invocation gets its own `ctx.db` and so cannot be reached by any
1328
+ * transaction-scoped invalidation.
1329
+ */
1330
+ let aggregateStateGeneration = 0;
1331
+ /**
1332
+ * Tables whose CLEARING range was read and found empty, with the generation
1333
+ * that read was valid at.
1334
+ *
1335
+ * The barrier runs from a before-hook, once per written row, so a 40-row
1336
+ * statement re-scanned the same empty range 40 times. Only the empty result is
1337
+ * memoized: a blocking state throws, so it never loops, and refusing to cache
1338
+ * it keeps `convex/orm/count.test.ts`'s interleaved state writes honest.
1339
+ */
1340
+ const clearingRangeEmptyAtGeneration = createOrmTransactionMemo();
1250
1341
  const assertAggregateIndexesWritable = async (db, tableName, metricIndexNames, rankIndexNames) => {
1342
+ const generation = aggregateStateGeneration;
1343
+ if (clearingRangeEmptyAtGeneration.get(db, tableName) === generation) return;
1251
1344
  const clearingStates = await db.query(AGGREGATE_STATE_TABLE).withIndex("by_table_status", (q) => q.eq("tableKey", tableName).eq("status", COUNT_STATUS_CLEARING)).collect();
1345
+ if (clearingStates.length === 0) {
1346
+ clearingRangeEmptyAtGeneration.set(db, tableName, generation);
1347
+ return;
1348
+ }
1252
1349
  const metricNames = new Set(metricIndexNames);
1253
1350
  const rankNames = new Set(rankIndexNames);
1254
1351
  const blockingState = clearingStates.find((state) => state.kind === AGGREGATE_STATE_KIND_RANK ? rankNames.has(state.indexName) : metricNames.has(state.indexName));
@@ -1269,6 +1366,7 @@ const isIndexStateDrained = async (db, kind, tableName, indexName) => {
1269
1366
  return bucket === null && extrema === null;
1270
1367
  };
1271
1368
  const setCountState = async (db, nextState, kind = AGGREGATE_STATE_KIND_METRIC) => {
1369
+ aggregateStateGeneration += 1;
1272
1370
  const existing = await getCountState(db, nextState.tableName, nextState.indexName, kind);
1273
1371
  const payload = {
1274
1372
  kind,
@@ -1,5 +1,5 @@
1
- import { $n as BinaryExpression, $t as OrmLifecycleOperation, A as DatabaseWithMutations, An as ConvexCheckConfig, Ar as AnyColumn, At as VectorQueryConfig, B as RlsContext, Bn as ConvexTextBuilderInitial, Br as IsUnique, Bt as RelationsBuilderColumnConfig, C as MigrationTableName, Cn as aggregateIndex, Cr as notBetween, Ct as OrderDirection, D as defineMigrationSet, Dn as uniqueIndex, Dt as ReturningResult, E as defineMigration, En as searchIndex, Er as startsWith, Et as ReturningAll, Fn as ConvexUniqueConstraintConfig, Fr as ColumnBuilderWithTableName, Ft as ExtractTablesWithRelations, Gt as defineRelations, H as EdgeMetadata, In as check, Ir as ColumnDataType, It as ManyConfig, Jt as ConvexDeletionConfig, Kt as defineRelationsPart, Ln as foreignKey, Lr as DrizzleEntity, Lt as OneConfig, M as OrmReader$1, Mn as ConvexForeignKeyConfig, Mr as ColumnBuilderBaseConfig, Mt as unsetToken, N as OrmWriter$1, Nn as ConvexUniqueConstraintBuilder, Nr as ColumnBuilderRuntimeConfig, O as detectMigrationDrift, On as vectorIndex, Or as SystemFields, Ot as ReturningSelection, Pn as ConvexUniqueConstraintBuilderOn, Pr as ColumnBuilderTypeConfig, Pt as ExtractTablesFromSchema, Qn as TableName, Qt as OrmLifecycleChange, Rn as unique, Rr as HasDefault, Rt as RelationsBuilder, S as MigrationStep, Sn as ConvexVectorIndexConfig, Sr as not, St as OrderByClause, T as buildMigrationPlan, Tn as rankIndex, Tr as or, Tt as PredicateWhereIndexConfig, U as extractRelationsConfig, Un as Brand, Ut as TableRelationalConfig, V as RlsMode, Vn as text, Vr as NotNull, Wn as Columns, Wt as TablesRelationalConfig, Xn as OrmSchemaRelations, Xt as ConvexTableWithColumns, Yn as OrmSchemaExtensions, Yt as ConvexTable, Zn as OrmSchemaTriggers, Zt as DiscriminatorBuilderConfig, _ as MigrationMigrateOne, _n as ConvexSearchIndexBuilder, _r as isNull, _t as MutationPaginateConfig, an as RlsPolicyConfig, ar as and, at as CountConfig, b as MigrationSet, bn as ConvexVectorIndexBuilder, br as lte, bt as MutationReturning, cn as RlsRole, cr as endsWith, ct as FilterOperators, d as MigrationDefinition, dn as ConvexAggregateIndexBuilder, dr as gt, dt as InferModelFromColumns, en as TableConfig, er as ExpressionVisitor, et as AggregateConfig, f as MigrationDirection, fn as ConvexAggregateIndexBuilderOn, fr as gte, ft as InferSelectModel, g as MigrationManifestEntry, gn as ConvexRankIndexBuilderOn, gr as isNotNull, gt as MutationExecutionMode, h as MigrationDriftIssue, hn as ConvexRankIndexBuilder, hr as isFieldReference, ht as MutationExecuteResult, i as OrmMigrationCapability, in as RlsPolicy, ir as UnaryExpression, it as BuildRelationResult, j as DatabaseWithQuery, jn as ConvexForeignKeyBuilder, jr as ColumnBuilder, jt as VectorSearchProvider, kn as ConvexCheckBuilder, kt as UpdateSet, ln as RlsRoleConfig, lr as eq, lt as GetColumnData, m as MigrationDocContext, mn as ConvexIndexBuilderOn, mr as inArray, mt as MutationExecuteConfig, n as OrmCapabilities, nn as deletion, nr as FilterExpression, nt as AggregateResult, on as RlsPolicyToOption, or as between, ot as CountResult, p as MigrationDoc, pn as ConvexIndexBuilder, pr as ilike, pt as InsertValue, qn as OrmSchemaExtensionTables, qt as ConvexDeletionBuilder, r as OrmCapability, rn as discriminator, rr as LogicalExpression, rt as BuildQueryResult, sn as rlsPolicy, sr as contains, st as DBQueryConfig, t as OrmAggregateCapability, tn as convexTable, tr as FieldReference, tt as AggregateFieldValue, u as MigrationAppliedState, un as rlsRole, ur as fieldRef, ut as InferInsertModel, v as MigrationPlan, vn as ConvexSearchIndexBuilderOn, vr as like, vt as MutationPaginatedResult, w as MigrationWriteMode, wn as index, wr as notInArray, wt as PaginatedResult, x as MigrationStateMap, xn as ConvexVectorIndexBuilderOn, xr as ne, xt as MutationRunMode, y as MigrationRunStatus, yn as ConvexSearchIndexConfig, yr as lt, yt as MutationResult, zn as ConvexTextBuilder, zr as IsPrimaryKey, zt as RelationsBuilderColumnBase } from "../capabilities-DkfnnNp7.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-CETRjurp.js";
1
+ import { $n as BinaryExpression, $t as OrmLifecycleOperation, A as DatabaseWithMutations, An as ConvexCheckConfig, Ar as AnyColumn, At as VectorQueryConfig, B as RlsContext, Bn as ConvexTextBuilderInitial, Br as IsUnique, Bt as RelationsBuilderColumnConfig, C as MigrationTableName, Cn as aggregateIndex, Cr as notBetween, Ct as OrderDirection, D as defineMigrationSet, Dn as uniqueIndex, Dt as ReturningResult, E as defineMigration, En as searchIndex, Er as startsWith, Et as ReturningAll, Fn as ConvexUniqueConstraintConfig, Fr as ColumnBuilderWithTableName, Ft as ExtractTablesWithRelations, Gt as defineRelations, H as EdgeMetadata, In as check, Ir as ColumnDataType, It as ManyConfig, Jt as ConvexDeletionConfig, Kt as defineRelationsPart, Ln as foreignKey, Lr as DrizzleEntity, Lt as OneConfig, M as OrmReader$1, Mn as ConvexForeignKeyConfig, Mr as ColumnBuilderBaseConfig, Mt as unsetToken, N as OrmWriter$1, Nn as ConvexUniqueConstraintBuilder, Nr as ColumnBuilderRuntimeConfig, O as detectMigrationDrift, On as vectorIndex, Or as SystemFields, Ot as ReturningSelection, Pn as ConvexUniqueConstraintBuilderOn, Pr as ColumnBuilderTypeConfig, Pt as ExtractTablesFromSchema, Qn as TableName, Qt as OrmLifecycleChange, Rn as unique, Rr as HasDefault, Rt as RelationsBuilder, S as MigrationStep, Sn as ConvexVectorIndexConfig, Sr as not, St as OrderByClause, T as buildMigrationPlan, Tn as rankIndex, Tr as or, Tt as PredicateWhereIndexConfig, U as extractRelationsConfig, Un as Brand, Ut as TableRelationalConfig, V as RlsMode, Vn as text, Vr as NotNull, Wn as Columns, Wt as TablesRelationalConfig, Xn as OrmSchemaRelations, Xt as ConvexTableWithColumns, Yn as OrmSchemaExtensions, Yt as ConvexTable, Zn as OrmSchemaTriggers, Zt as DiscriminatorBuilderConfig, _ as MigrationMigrateOne, _n as ConvexSearchIndexBuilder, _r as isNull, _t as MutationPaginateConfig, an as RlsPolicyConfig, ar as and, at as CountConfig, b as MigrationSet, bn as ConvexVectorIndexBuilder, br as lte, bt as MutationReturning, cn as RlsRole, cr as endsWith, ct as FilterOperators, d as MigrationDefinition, dn as ConvexAggregateIndexBuilder, dr as gt, dt as InferModelFromColumns, en as TableConfig, er as ExpressionVisitor, et as AggregateConfig, f as MigrationDirection, fn as ConvexAggregateIndexBuilderOn, fr as gte, ft as InferSelectModel, g as MigrationManifestEntry, gn as ConvexRankIndexBuilderOn, gr as isNotNull, gt as MutationExecutionMode, h as MigrationDriftIssue, hn as ConvexRankIndexBuilder, hr as isFieldReference, ht as MutationExecuteResult, i as OrmMigrationCapability, in as RlsPolicy, ir as UnaryExpression, it as BuildRelationResult, j as DatabaseWithQuery, jn as ConvexForeignKeyBuilder, jr as ColumnBuilder, jt as VectorSearchProvider, kn as ConvexCheckBuilder, kt as UpdateSet, ln as RlsRoleConfig, lr as eq, lt as GetColumnData, m as MigrationDocContext, mn as ConvexIndexBuilderOn, mr as inArray, mt as MutationExecuteConfig, n as OrmCapabilities, nn as deletion, nr as FilterExpression, nt as AggregateResult, on as RlsPolicyToOption, or as between, ot as CountResult, p as MigrationDoc, pn as ConvexIndexBuilder, pr as ilike, pt as InsertValue, qn as OrmSchemaExtensionTables, qt as ConvexDeletionBuilder, r as OrmCapability, rn as discriminator, rr as LogicalExpression, rt as BuildQueryResult, sn as rlsPolicy, sr as contains, st as DBQueryConfig, t as OrmAggregateCapability, tn as convexTable, tr as FieldReference, tt as AggregateFieldValue, u as MigrationAppliedState, un as rlsRole, ur as fieldRef, ut as InferInsertModel, v as MigrationPlan, vn as ConvexSearchIndexBuilderOn, vr as like, vt as MutationPaginatedResult, w as MigrationWriteMode, wn as index, wr as notInArray, wt as PaginatedResult, x as MigrationStateMap, xn as ConvexVectorIndexBuilderOn, xr as ne, xt as MutationRunMode, y as MigrationRunStatus, yn as ConvexSearchIndexConfig, yr as lt, yt as MutationResult, zn as ConvexTextBuilder, zr as IsPrimaryKey, zt as RelationsBuilderColumnBase } from "../capabilities-BAiI8avr.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-DdAw9rNV.js";
3
3
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-wOIjhkfN.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-DJONf8X5.js";
5
5
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
package/dist/orm/index.js CHANGED
@@ -4,7 +4,7 @@ import { a as pretendRequired, i as pretend, n as deprecated } from "../validato
4
4
  import { t as id } from "../id-CuSfWa5q.js";
5
5
  import { A as or, C as matchLikePattern, D as notIlike, E as notBetween, O as notInArray, S as lte, T as not, _ as isFieldReference, a as between, b as like, c as endsWith, d as filterValueInList, f as filterValuesEqual, g as inArray, h as ilike, i as arrayOverlaps, j as startsWith, k as notLike, l as eq, m as gte, n as arrayContained, o as column, p as gt, r as arrayContains, s as contains, t as and, u as fieldRef, v as isNotNull, w as ne, x as lt, y as isNull } from "../filter-expression-Dydt8wS0.js";
6
6
  import { a as indexKeyWithinBounds, c as streamIndexRange, i as getIndexFields, l as isUnsetToken, n as EmptyStream, o as mergedStream, r as QueryStream, s as stream, t as getByIdWithOrmQueryFallback, u as unsetToken } from "../query-context-DOm5Xm3H.js";
7
- import { $ as resolveOrmRuntimeDefaults, A as enforceUniqueIndexes, B as getMutationAsyncDelayMs, C as collectPrimaryIdLookupRows, Ct as CREATED_AT_MIGRATION_MESSAGE, D as enforceCheckConstraints, E as encodeUndefinedDeep, Et as usesSystemCreatedAtAlias, F as evaluateFilter, G as getTableDeleteConfig, H as getMutationExecutionMode, I as extractPrimaryIdLookup, J as hardDeleteRow, K as getTableName, L as getChecks, M as ensureNonNullValues, N as ensureNullableColumns, O as enforceForeignKeys, P as evaluateCheckConstraintTriState, Q as patchReferencingRows, R as getColumnName$1, S as collectMutationRowsBounded, St as resolveIndexOrderPushdown, T as deserializeFilterExpression, Tt as PUBLIC_CREATED_AT_FIELD, U as getOrmContext, V as getMutationCollectionLimits, W as getTableColumns$2, X as normalizeDateFieldsForWrite, Y as hydrateDateFieldsForRead, Z as normalizeTemporalComparableValue, _ as applyDefaults, _t as findSearchIndexByName, at as stripUnsetFields, b as buildForeignKeyGraph, bt as getIndexes, c as getAggregateIndexDefinitions, ct as unsetFieldsOf, d as COUNT_ERROR, dt as compileConvexFilter, et as returningSelectionReadsCreationTime, f as createAggregateError, ft as convexAnd, g as ensureCountAllowedForRls, gt as findRelationIndex, h as ensureAggregateAllowedForRls, ht as findIndexForColumns, it as splitReturningSelection, j as ensureDefaultColumns, k as enforcePolymorphicWrite, l as getRankIndexDefinitions, lt as hasLifecycleHooks, mt as mapWithConcurrency, nt as serializeFilterExpression, o as aggregateExtension, ot as takeRowsWithinByteBudget, p as createCountError, pt as isConvexEnforceableFilter, q as getUniqueIndexes, rt as softDeleteRow, st as toConvexFilter, tt as selectReturningRowWithHydration, u as AGGREGATE_ERROR, ut as markLifecycleHookedTables, v as applyIncomingForeignKeyActionsOnDelete, vt as findVectorIndexByName, w as decodeUndefinedDeep, wt as INTERNAL_CREATION_TIME_FIELD, x as canUsePrimaryIdLookupCursor, xt as getRankIndexes, y as applyIncomingForeignKeyActionsOnUpdate, yt as getAggregateIndexes, z as getForeignKeys } from "../schema-D95Z3Kss.js";
7
+ import { $ as patchReferencingRows, A as enforcePolymorphicWrite, B as getForeignKeys, C as collectPrimaryIdLookupRows, Ct as resolveIndexOrderPushdown, D as encodeUndefinedDeep, Dt as usesSystemCreatedAtAlias, E as deserializeFilterExpression, Et as PUBLIC_CREATED_AT_FIELD, F as evaluateCheckConstraintTriState, G as getTableColumns$2, H as getMutationCollectionLimits, I as evaluateFilter, J as getUniqueIndexes, K as getTableDeleteConfig, L as extractPrimaryIdLookup, M as ensureDefaultColumns, N as ensureNonNullValues, O as enforceCheckConstraints, P as ensureNullableColumns, Q as normalizeTemporalComparableValue, R as getChecks, S as collectMutationRowsBounded, St as getRankIndexes, T as decodeUndefinedDeep, Tt as INTERNAL_CREATION_TIME_FIELD, U as getMutationExecutionMode, V as getMutationAsyncDelayMs, W as getOrmContext, X as hydrateDateFieldsForRead, Y as hardDeleteRow, Z as normalizeDateFieldsForWrite, _ as applyDefaults, _t as findRelationIndex, at as splitReturningSelection, b as buildForeignKeyGraph, bt as getAggregateIndexes, c as getAggregateIndexDefinitions, ct as toConvexFilter, d as COUNT_ERROR, dt as markLifecycleHookedTables, et as resolveOrmRuntimeDefaults, f as createAggregateError, ft as compileConvexFilter, g as ensureCountAllowedForRls, gt as findIndexForColumns, h as ensureAggregateAllowedForRls, ht as mapWithConcurrency, it as softDeleteRow, j as enforceUniqueIndexes, k as enforceForeignKeys, l as getRankIndexDefinitions, lt as unsetFieldsOf, mt as isConvexEnforceableFilter, nt as selectReturningRowWithHydration, o as aggregateExtension, ot as stripUnsetFields, p as createCountError, pt as convexAnd, q as getTableName, rt as serializeFilterExpression, st as takeRowsWithinByteBudget, tt as returningSelectionReadsCreationTime, u as AGGREGATE_ERROR, ut as hasLifecycleHooks, v as applyIncomingForeignKeyActionsOnDelete, vt as findSearchIndexByName, w as createForeignKeyProbeMemo, wt as CREATED_AT_MIGRATION_MESSAGE, x as canUsePrimaryIdLookupCursor, xt as getIndexes, y as applyIncomingForeignKeyActionsOnUpdate, yt as findVectorIndexByName, z as getColumnName$1 } from "../schema-CzdjX7nx.js";
8
8
  import { t as defineSchemaExtension } from "../extensions-Blzsyekm.js";
9
9
  import { compareValues, convexToJson, jsonToConvex, v } from "convex/values";
10
10
  import { defineSchema as defineSchema$1, internalActionGeneric, internalMutationGeneric } from "convex/server";
@@ -1543,6 +1543,22 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
1543
1543
  * hands it to the next run rather than re-probing.
1544
1544
  */
1545
1545
  _aggregateIndexReadinessByKey = /* @__PURE__ */ new Map();
1546
+ /**
1547
+ * Documents resolved by id during one execution, keyed on the normalized id.
1548
+ *
1549
+ * A relation `where` never compiles into the index plan, so it runs as a
1550
+ * post-fetch membership predicate over a residual stream — one row at a time.
1551
+ * Every de-duplication map inside the relation loaders is scoped to the batch
1552
+ * it is handed, and a batch of one makes all of them no-ops, so a page whose
1553
+ * rows share two parents re-read those two documents once per scanned row.
1554
+ *
1555
+ * Scoped to one execution, like `_rlsPolicyResolution`: `_executionClaimed`
1556
+ * diverts later executions to a fresh instance, and an execution reads
1557
+ * without writing, so a hit is always the document the caller would have read
1558
+ * for itself. It must not be handed to the next run by `_forExecution` — an
1559
+ * intervening write would make it stale.
1560
+ */
1561
+ _documentByNormalizedId = /* @__PURE__ */ new Map();
1546
1562
  constructor(schema, tableConfig, edgeMetadata, db, config, mode, _allEdges, rls, relationLoading, vectorSearchProvider, configuredIndex, countIndexReadiness) {
1547
1563
  super();
1548
1564
  this.schema = schema;
@@ -4428,7 +4444,15 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
4428
4444
  async _getById(tableName, id) {
4429
4445
  if (id === null || id === void 0) return null;
4430
4446
  const normalizedId = this.db.normalizeId(tableName, id);
4431
- return normalizedId === null ? null : await this.db.get(normalizedId);
4447
+ if (normalizedId === null) return null;
4448
+ const existing = this._documentByNormalizedId.get(normalizedId);
4449
+ if (existing) return await existing;
4450
+ const pending = Promise.resolve(this.db.get(normalizedId)).catch((error) => {
4451
+ this._documentByNormalizedId.delete(normalizedId);
4452
+ throw error;
4453
+ });
4454
+ this._documentByNormalizedId.set(normalizedId, pending);
4455
+ return await pending;
4432
4456
  }
4433
4457
  _getRelationConcurrency() {
4434
4458
  const value = this.relationLoading?.concurrency;
@@ -5552,6 +5576,8 @@ var ConvexInsertBuilder = class extends QueryPromise {
5552
5576
  const ormContext = getOrmContext(this.db);
5553
5577
  const tableName = getTableName(this.table);
5554
5578
  const returningSelection = this.returningFields && this.returningFields !== true ? splitReturningSelection(this.returningFields) : void 0;
5579
+ const statementTableName = getTableName(this.table);
5580
+ const probedForeignIds = hasLifecycleHooks(this.db, statementTableName) ? void 0 : createForeignKeyProbeMemo();
5555
5581
  const derivedRowSatisfiesCount = returningSelection?.countSelection === void 0 || !countedEdgesReadCreationTime(ormContext?.edgeMetadata, tableName) && !isRlsEnabled(this.table);
5556
5582
  const canDerivePostImage = returningSelection !== void 0 && !hasLifecycleHooks(this.db, tableName) && !returningSelectionReadsCreationTime(returningSelection.columnSelection) && derivedRowSatisfiesCount;
5557
5583
  const results = [];
@@ -5566,14 +5592,17 @@ var ConvexInsertBuilder = class extends QueryPromise {
5566
5592
  row: preparedValue,
5567
5593
  rls
5568
5594
  })) throw new Error(`RLS policy violation for insert on table "${tableName}"`);
5569
- const conflictResult = await this.handleConflict(preparedValue, rlsResolution);
5595
+ const conflictResult = await this.handleConflict(preparedValue, rlsResolution, probedForeignIds);
5570
5596
  if (conflictResult?.status === "skip") continue;
5571
5597
  if (conflictResult?.status === "updated") {
5572
5598
  if (conflictResult.row && this.returningFields) results.push(await this.resolveReturningRow(conflictResult.row, returningSelection, ormContext));
5573
5599
  continue;
5574
5600
  }
5575
5601
  enforceCheckConstraints(this.table, preparedValue);
5576
- await enforceForeignKeys(this.db, this.table, preparedValue, { changedFields: new Set(Object.keys(preparedValue)) });
5602
+ await enforceForeignKeys(this.db, this.table, preparedValue, {
5603
+ changedFields: new Set(Object.keys(preparedValue)),
5604
+ probed: probedForeignIds
5605
+ });
5577
5606
  await enforceUniqueIndexes(this.db, this.table, preparedValue, { changedFields: new Set(Object.keys(preparedValue)) });
5578
5607
  const id = await this.db.insert(tableName, preparedValue);
5579
5608
  if (!this.returningFields) continue;
@@ -5592,7 +5621,7 @@ var ConvexInsertBuilder = class extends QueryPromise {
5592
5621
  if (returningSelection?.countSelection) selected._count = await this._loadReturningCount(row, returningSelection.countSelection, ormContext);
5593
5622
  return selected;
5594
5623
  }
5595
- async handleConflict(value, rlsResolution) {
5624
+ async handleConflict(value, rlsResolution, probedForeignIds) {
5596
5625
  if (!this.conflictConfig) return;
5597
5626
  const { action, config } = this.conflictConfig;
5598
5627
  const targetColumns = Array.isArray(config.target) ? config.target : config.target ? [config.target] : [];
@@ -5660,7 +5689,10 @@ var ConvexInsertBuilder = class extends QueryPromise {
5660
5689
  };
5661
5690
  enforceCheckConstraints(this.table, candidate);
5662
5691
  return candidate;
5663
- })(), { changedFields: new Set(Object.keys(writeSet)) });
5692
+ })(), {
5693
+ changedFields: new Set(Object.keys(writeSet)),
5694
+ probed: probedForeignIds
5695
+ });
5664
5696
  await enforceUniqueIndexes(this.db, this.table, {
5665
5697
  ...existing,
5666
5698
  ...writeSet
@@ -1,3 +1,3 @@
1
- import { C as MigrationTableName, D as defineMigrationSet, E as defineMigration, O as detectMigrationDrift, S as MigrationStep, T as buildMigrationPlan, _ as MigrationMigrateOne, a as MigrationCancelArgs, b as MigrationSet, c as MigrationStatusArgs, d as MigrationDefinition, f as MigrationDirection, g as MigrationManifestEntry, h as MigrationDriftIssue, l as createMigrationHandlers, m as MigrationDocContext, o as MigrationRunArgs, p as MigrationDoc, s as MigrationRunChunkArgs, u as MigrationAppliedState, v as MigrationPlan, w as MigrationWriteMode, x as MigrationStateMap, y as MigrationRunStatus } from "../../capabilities-DkfnnNp7.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-CETRjurp.js";
1
+ import { C as MigrationTableName, D as defineMigrationSet, E as defineMigration, O as detectMigrationDrift, S as MigrationStep, T as buildMigrationPlan, _ as MigrationMigrateOne, a as MigrationCancelArgs, b as MigrationSet, c as MigrationStatusArgs, d as MigrationDefinition, f as MigrationDirection, g as MigrationManifestEntry, h as MigrationDriftIssue, l as createMigrationHandlers, m as MigrationDocContext, o as MigrationRunArgs, p as MigrationDoc, s as MigrationRunChunkArgs, u as MigrationAppliedState, v as MigrationPlan, w as MigrationWriteMode, x as MigrationStateMap, y as MigrationRunStatus } from "../../capabilities-BAiI8avr.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-DdAw9rNV.js";
3
3
  export { 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 };
@@ -852,18 +852,22 @@ async function enforceUniqueIndexes(db, table, candidate, options) {
852
852
  if (existing !== null && (options?.currentId === void 0 || existing._id !== options.currentId)) throw new Error(`Unique index '${index.name}' violation on '${tableName}'.`);
853
853
  }
854
854
  }
855
+ const createForeignKeyProbeMemo = () => /* @__PURE__ */ new Set();
855
856
  async function enforceForeignKeys(db, table, candidate, options) {
856
857
  const foreignKeys = getForeignKeys(table);
857
858
  if (foreignKeys.length === 0) return;
858
859
  const tableName = getTableName(table);
859
860
  const changedFields = options?.changedFields;
861
+ const probed = options?.probed;
860
862
  for (const foreignKey of foreignKeys) {
861
863
  if (changedFields && !foreignKey.columns.some((field) => changedFields.has(field))) continue;
862
864
  const entries = foreignKey.columns.map((field) => [field, candidate[field]]);
863
865
  if (entries.some(([, value]) => value === void 0 || value === null)) continue;
864
866
  if (foreignKey.foreignColumns.length === 1 && foreignKey.foreignColumns[0] === "_id") {
865
867
  const foreignId = entries[0]?.[1];
868
+ if (probed?.has(foreignId)) continue;
866
869
  if (!await db.get(foreignId)) throw new Error(`Foreign key violation on '${tableName}': missing document in '${foreignKey.foreignTableName}'.`);
870
+ probed?.add(foreignId);
867
871
  continue;
868
872
  }
869
873
  if (!foreignKey.foreignTable) throw new Error(`Foreign key on '${tableName}' requires indexed foreign columns on '${foreignKey.foreignTableName}'.`);
@@ -1522,4 +1526,4 @@ function aggregateExtension() {
1522
1526
  }
1523
1527
 
1524
1528
  //#endregion
1525
- export { resolveOrmRuntimeDefaults as $, enforceUniqueIndexes as A, getMutationAsyncDelayMs as B, collectPrimaryIdLookupRows as C, CREATED_AT_MIGRATION_MESSAGE as Ct, enforceCheckConstraints as D, encodeUndefinedDeep as E, usesSystemCreatedAtAlias as Et, evaluateFilter as F, getTableDeleteConfig as G, getMutationExecutionMode as H, extractPrimaryIdLookup as I, hardDeleteRow as J, getTableName as K, getChecks as L, ensureNonNullValues as M, ensureNullableColumns as N, enforceForeignKeys as O, evaluateCheckConstraintTriState as P, patchReferencingRows as Q, getColumnName as R, collectMutationRowsBounded as S, resolveIndexOrderPushdown as St, deserializeFilterExpression as T, PUBLIC_CREATED_AT_FIELD as Tt, getOrmContext as U, getMutationCollectionLimits as V, getTableColumns as W, normalizeDateFieldsForWrite as X, hydrateDateFieldsForRead as Y, normalizeTemporalComparableValue as Z, applyDefaults as _, findSearchIndexByName as _t, AGGREGATE_STATE_TABLE as a, stripUnsetFields as at, buildForeignKeyGraph as b, getIndexes as bt, getAggregateIndexDefinitions as c, unsetFieldsOf as ct, COUNT_ERROR as d, compileConvexFilter as dt, returningSelectionReadsCreationTime as et, createAggregateError as f, convexAnd as ft, ensureCountAllowedForRls as g, findRelationIndex as gt, ensureAggregateAllowedForRls as h, findIndexForColumns as ht, AGGREGATE_RANK_TREE_TABLE as i, splitReturningSelection as it, ensureDefaultColumns as j, enforcePolymorphicWrite as k, getRankIndexDefinitions as l, hasLifecycleHooks as lt, createError as m, mapWithConcurrency as mt, AGGREGATE_EXTREMA_TABLE as n, serializeFilterExpression as nt, aggregateExtension as o, takeRowsWithinByteBudget as ot, createCountError as p, isConvexEnforceableFilter as pt, getUniqueIndexes as q, AGGREGATE_MEMBER_TABLE as r, softDeleteRow as rt, rankAggregateName as s, toConvexFilter as st, AGGREGATE_BUCKET_TABLE as t, selectReturningRowWithHydration as tt, AGGREGATE_ERROR as u, markLifecycleHookedTables as ut, applyIncomingForeignKeyActionsOnDelete as v, findVectorIndexByName as vt, decodeUndefinedDeep as w, INTERNAL_CREATION_TIME_FIELD as wt, canUsePrimaryIdLookupCursor as x, getRankIndexes as xt, applyIncomingForeignKeyActionsOnUpdate as y, getAggregateIndexes as yt, getForeignKeys as z };
1529
+ export { patchReferencingRows as $, enforcePolymorphicWrite as A, getForeignKeys as B, collectPrimaryIdLookupRows as C, resolveIndexOrderPushdown as Ct, encodeUndefinedDeep as D, usesSystemCreatedAtAlias as Dt, deserializeFilterExpression as E, PUBLIC_CREATED_AT_FIELD as Et, evaluateCheckConstraintTriState as F, getTableColumns as G, getMutationCollectionLimits as H, evaluateFilter as I, getUniqueIndexes as J, getTableDeleteConfig as K, extractPrimaryIdLookup as L, ensureDefaultColumns as M, ensureNonNullValues as N, enforceCheckConstraints as O, ensureNullableColumns as P, normalizeTemporalComparableValue as Q, getChecks as R, collectMutationRowsBounded as S, getRankIndexes as St, decodeUndefinedDeep as T, INTERNAL_CREATION_TIME_FIELD as Tt, getMutationExecutionMode as U, getMutationAsyncDelayMs as V, getOrmContext as W, hydrateDateFieldsForRead as X, hardDeleteRow as Y, normalizeDateFieldsForWrite as Z, applyDefaults as _, findRelationIndex as _t, AGGREGATE_STATE_TABLE as a, splitReturningSelection as at, buildForeignKeyGraph as b, getAggregateIndexes as bt, getAggregateIndexDefinitions as c, toConvexFilter as ct, COUNT_ERROR as d, markLifecycleHookedTables as dt, resolveOrmRuntimeDefaults as et, createAggregateError as f, compileConvexFilter as ft, ensureCountAllowedForRls as g, findIndexForColumns as gt, ensureAggregateAllowedForRls as h, mapWithConcurrency as ht, AGGREGATE_RANK_TREE_TABLE as i, softDeleteRow as it, enforceUniqueIndexes as j, enforceForeignKeys as k, getRankIndexDefinitions as l, unsetFieldsOf as lt, createError as m, isConvexEnforceableFilter as mt, AGGREGATE_EXTREMA_TABLE as n, selectReturningRowWithHydration as nt, aggregateExtension as o, stripUnsetFields as ot, createCountError as p, convexAnd as pt, getTableName as q, AGGREGATE_MEMBER_TABLE as r, serializeFilterExpression as rt, rankAggregateName as s, takeRowsWithinByteBudget as st, AGGREGATE_BUCKET_TABLE as t, returningSelectionReadsCreationTime as tt, AGGREGATE_ERROR as u, hasLifecycleHooks as ut, applyIncomingForeignKeyActionsOnDelete as v, findSearchIndexByName as vt, createForeignKeyProbeMemo as w, CREATED_AT_MIGRATION_MESSAGE as wt, canUsePrimaryIdLookupCursor as x, getIndexes as xt, applyIncomingForeignKeyActionsOnUpdate as y, findVectorIndexByName as yt, getColumnName as z };
@@ -1,4 +1,4 @@
1
- import { Bn as ConvexTextBuilderInitial, Dr as SystemFieldAliases, F as DeleteMode, Gn as OrmRuntimeDefaults, H as EdgeMetadata, Hn as ConvexColumnBuilder, Hr as entityKind, Ht as RelationsConfigWithSchema, I as SerializedFilterExpression, Jn as OrmSchemaExtensionTriggers, Kn as OrmSchemaExtensionRelations, L as getChecks, M as OrmReader, Mr as ColumnBuilderBaseConfig, N as OrmWriter, Nt as AnyRelationsBuilderConfig, Or as SystemFields, P as CascadeMode, Pt as ExtractTablesFromSchema, Qt as OrmLifecycleChange, R as getForeignKeys, Rr as HasDefault, Rt as RelationsBuilder, St as OrderByClause, Ut as TableRelationalConfig, Vt as RelationsBuilderConfigValue, Wn as Columns, Wt as TablesRelationalConfig, Xn as OrmSchemaRelations, Xt as ConvexTableWithColumns, Yt as ConvexTable, Zn as OrmSchemaTriggers, b as MigrationSet, ft as InferSelectModel, in as RlsPolicy, jr as ColumnBuilder, jt as VectorSearchProvider, k as CreateDatabaseOptions, kr as $Type, nr as FilterExpression$1, r as OrmCapability, ut as InferInsertModel, z as getUniqueIndexes } from "./capabilities-DkfnnNp7.js";
1
+ import { Bn as ConvexTextBuilderInitial, Dr as SystemFieldAliases, F as DeleteMode, Gn as OrmRuntimeDefaults, H as EdgeMetadata, Hn as ConvexColumnBuilder, Hr as entityKind, Ht as RelationsConfigWithSchema, I as SerializedFilterExpression, Jn as OrmSchemaExtensionTriggers, Kn as OrmSchemaExtensionRelations, L as getChecks, M as OrmReader, Mr as ColumnBuilderBaseConfig, N as OrmWriter, Nt as AnyRelationsBuilderConfig, Or as SystemFields, P as CascadeMode, Pt as ExtractTablesFromSchema, Qt as OrmLifecycleChange, R as getForeignKeys, Rr as HasDefault, Rt as RelationsBuilder, St as OrderByClause, Ut as TableRelationalConfig, Vt as RelationsBuilderConfigValue, Wn as Columns, Wt as TablesRelationalConfig, Xn as OrmSchemaRelations, Xt as ConvexTableWithColumns, Yt as ConvexTable, Zn as OrmSchemaTriggers, b as MigrationSet, ft as InferSelectModel, in as RlsPolicy, jr as ColumnBuilder, jt as VectorSearchProvider, k as CreateDatabaseOptions, kr as $Type, nr as FilterExpression$1, r as OrmCapability, ut as InferInsertModel, z as getUniqueIndexes } from "./capabilities-BAiI8avr.js";
2
2
  import * as convex_values0 from "convex/values";
3
3
  import { GenericId, Validator, Value } from "convex/values";
4
4
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchedulableFunctionReference, Scheduler, SchemaDefinition, internalActionGeneric, internalMutationGeneric } from "convex/server";
@@ -102,15 +102,6 @@ declare const migrationStorageTables: {
102
102
  fieldName: "status";
103
103
  };
104
104
  };
105
- cursor: ConvexTextBuilderInitial<""> & {
106
- _: {
107
- tableName: "migration_state";
108
- };
109
- } & {
110
- _: {
111
- fieldName: "cursor";
112
- };
113
- };
114
105
  direction: ConvexTextBuilderInitial<""> & {
115
106
  _: {
116
107
  tableName: "migration_state";
@@ -120,17 +111,13 @@ declare const migrationStorageTables: {
120
111
  fieldName: "direction";
121
112
  };
122
113
  };
123
- updatedAt: ConvexNumberBuilderInitial<""> & {
124
- _: {
125
- notNull: true;
126
- };
127
- } & {
114
+ cursor: ConvexTextBuilderInitial<""> & {
128
115
  _: {
129
116
  tableName: "migration_state";
130
117
  };
131
118
  } & {
132
119
  _: {
133
- fieldName: "updatedAt";
120
+ fieldName: "cursor";
134
121
  };
135
122
  };
136
123
  migrationId: ConvexTextBuilderInitial<""> & {
@@ -203,6 +190,19 @@ declare const migrationStorageTables: {
203
190
  fieldName: "startedAt";
204
191
  };
205
192
  };
193
+ updatedAt: ConvexNumberBuilderInitial<""> & {
194
+ _: {
195
+ notNull: true;
196
+ };
197
+ } & {
198
+ _: {
199
+ tableName: "migration_state";
200
+ };
201
+ } & {
202
+ _: {
203
+ fieldName: "updatedAt";
204
+ };
205
+ };
206
206
  completedAt: ConvexNumberBuilderInitial<""> & {
207
207
  _: {
208
208
  tableName: "migration_state";
@@ -269,7 +269,7 @@ declare const migrationStorageTables: {
269
269
  fieldName: "direction";
270
270
  };
271
271
  };
272
- updatedAt: ConvexNumberBuilderInitial<""> & {
272
+ runId: ConvexTextBuilderInitial<""> & {
273
273
  _: {
274
274
  notNull: true;
275
275
  };
@@ -279,10 +279,10 @@ declare const migrationStorageTables: {
279
279
  };
280
280
  } & {
281
281
  _: {
282
- fieldName: "updatedAt";
282
+ fieldName: "runId";
283
283
  };
284
284
  };
285
- runId: ConvexTextBuilderInitial<""> & {
285
+ startedAt: ConvexNumberBuilderInitial<""> & {
286
286
  _: {
287
287
  notNull: true;
288
288
  };
@@ -292,10 +292,10 @@ declare const migrationStorageTables: {
292
292
  };
293
293
  } & {
294
294
  _: {
295
- fieldName: "runId";
295
+ fieldName: "startedAt";
296
296
  };
297
297
  };
298
- startedAt: ConvexNumberBuilderInitial<""> & {
298
+ updatedAt: ConvexNumberBuilderInitial<""> & {
299
299
  _: {
300
300
  notNull: true;
301
301
  };
@@ -305,7 +305,7 @@ declare const migrationStorageTables: {
305
305
  };
306
306
  } & {
307
307
  _: {
308
- fieldName: "startedAt";
308
+ fieldName: "updatedAt";
309
309
  };
310
310
  };
311
311
  completedAt: ConvexNumberBuilderInitial<""> & {
@@ -1008,7 +1008,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1008
1008
  readonly aggregate_bucket: ConvexTableWithColumns<{
1009
1009
  name: "aggregate_bucket";
1010
1010
  columns: {
1011
- count: ConvexNumberBuilderInitial<""> & {
1011
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1012
1012
  _: {
1013
1013
  notNull: true;
1014
1014
  };
@@ -1018,10 +1018,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1018
1018
  };
1019
1019
  } & {
1020
1020
  _: {
1021
- fieldName: "count";
1021
+ fieldName: "updatedAt";
1022
1022
  };
1023
1023
  };
1024
- updatedAt: ConvexNumberBuilderInitial<""> & {
1024
+ count: ConvexNumberBuilderInitial<""> & {
1025
1025
  _: {
1026
1026
  notNull: true;
1027
1027
  };
@@ -1031,7 +1031,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1031
1031
  };
1032
1032
  } & {
1033
1033
  _: {
1034
- fieldName: "updatedAt";
1034
+ fieldName: "count";
1035
1035
  };
1036
1036
  };
1037
1037
  tableKey: ConvexTextBuilderInitial<""> & {
@@ -1340,7 +1340,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1340
1340
  fieldName: "value";
1341
1341
  };
1342
1342
  };
1343
- count: ConvexNumberBuilderInitial<""> & {
1343
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1344
1344
  _: {
1345
1345
  notNull: true;
1346
1346
  };
@@ -1350,10 +1350,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1350
1350
  };
1351
1351
  } & {
1352
1352
  _: {
1353
- fieldName: "count";
1353
+ fieldName: "updatedAt";
1354
1354
  };
1355
1355
  };
1356
- updatedAt: ConvexNumberBuilderInitial<""> & {
1356
+ count: ConvexNumberBuilderInitial<""> & {
1357
1357
  _: {
1358
1358
  notNull: true;
1359
1359
  };
@@ -1363,7 +1363,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1363
1363
  };
1364
1364
  } & {
1365
1365
  _: {
1366
- fieldName: "updatedAt";
1366
+ fieldName: "count";
1367
1367
  };
1368
1368
  };
1369
1369
  tableKey: ConvexTextBuilderInitial<""> & {
@@ -1589,29 +1589,29 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1589
1589
  fieldName: "status";
1590
1590
  };
1591
1591
  };
1592
- cursor: ConvexTextBuilderInitial<""> & {
1592
+ kind: ConvexTextBuilderInitial<""> & {
1593
1593
  _: {
1594
- tableName: "aggregate_state";
1594
+ notNull: true;
1595
1595
  };
1596
1596
  } & {
1597
1597
  _: {
1598
- fieldName: "cursor";
1598
+ tableName: "aggregate_state";
1599
1599
  };
1600
- };
1601
- kind: ConvexTextBuilderInitial<""> & {
1600
+ } & {
1602
1601
  _: {
1603
- notNull: true;
1602
+ fieldName: "kind";
1604
1603
  };
1605
- } & {
1604
+ };
1605
+ cursor: ConvexTextBuilderInitial<""> & {
1606
1606
  _: {
1607
1607
  tableName: "aggregate_state";
1608
1608
  };
1609
1609
  } & {
1610
1610
  _: {
1611
- fieldName: "kind";
1611
+ fieldName: "cursor";
1612
1612
  };
1613
1613
  };
1614
- updatedAt: ConvexNumberBuilderInitial<""> & {
1614
+ processed: ConvexNumberBuilderInitial<""> & {
1615
1615
  _: {
1616
1616
  notNull: true;
1617
1617
  };
@@ -1621,10 +1621,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1621
1621
  };
1622
1622
  } & {
1623
1623
  _: {
1624
- fieldName: "updatedAt";
1624
+ fieldName: "processed";
1625
1625
  };
1626
1626
  };
1627
- processed: ConvexNumberBuilderInitial<""> & {
1627
+ startedAt: ConvexNumberBuilderInitial<""> & {
1628
1628
  _: {
1629
1629
  notNull: true;
1630
1630
  };
@@ -1634,10 +1634,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1634
1634
  };
1635
1635
  } & {
1636
1636
  _: {
1637
- fieldName: "processed";
1637
+ fieldName: "startedAt";
1638
1638
  };
1639
1639
  };
1640
- startedAt: ConvexNumberBuilderInitial<""> & {
1640
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1641
1641
  _: {
1642
1642
  notNull: true;
1643
1643
  };
@@ -1647,7 +1647,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1647
1647
  };
1648
1648
  } & {
1649
1649
  _: {
1650
- fieldName: "startedAt";
1650
+ fieldName: "updatedAt";
1651
1651
  };
1652
1652
  };
1653
1653
  completedAt: ConvexNumberBuilderInitial<""> & {
@@ -1744,15 +1744,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1744
1744
  fieldName: "status";
1745
1745
  };
1746
1746
  };
1747
- cursor: ConvexTextBuilderInitial<""> & {
1748
- _: {
1749
- tableName: "migration_state";
1750
- };
1751
- } & {
1752
- _: {
1753
- fieldName: "cursor";
1754
- };
1755
- };
1756
1747
  direction: ConvexTextBuilderInitial<""> & {
1757
1748
  _: {
1758
1749
  tableName: "migration_state";
@@ -1762,17 +1753,13 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1762
1753
  fieldName: "direction";
1763
1754
  };
1764
1755
  };
1765
- updatedAt: ConvexNumberBuilderInitial<""> & {
1766
- _: {
1767
- notNull: true;
1768
- };
1769
- } & {
1756
+ cursor: ConvexTextBuilderInitial<""> & {
1770
1757
  _: {
1771
1758
  tableName: "migration_state";
1772
1759
  };
1773
1760
  } & {
1774
1761
  _: {
1775
- fieldName: "updatedAt";
1762
+ fieldName: "cursor";
1776
1763
  };
1777
1764
  };
1778
1765
  migrationId: ConvexTextBuilderInitial<""> & {
@@ -1845,6 +1832,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1845
1832
  fieldName: "startedAt";
1846
1833
  };
1847
1834
  };
1835
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1836
+ _: {
1837
+ notNull: true;
1838
+ };
1839
+ } & {
1840
+ _: {
1841
+ tableName: "migration_state";
1842
+ };
1843
+ } & {
1844
+ _: {
1845
+ fieldName: "updatedAt";
1846
+ };
1847
+ };
1848
1848
  completedAt: ConvexNumberBuilderInitial<""> & {
1849
1849
  _: {
1850
1850
  tableName: "migration_state";
@@ -1911,7 +1911,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1911
1911
  fieldName: "direction";
1912
1912
  };
1913
1913
  };
1914
- updatedAt: ConvexNumberBuilderInitial<""> & {
1914
+ runId: ConvexTextBuilderInitial<""> & {
1915
1915
  _: {
1916
1916
  notNull: true;
1917
1917
  };
@@ -1921,10 +1921,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1921
1921
  };
1922
1922
  } & {
1923
1923
  _: {
1924
- fieldName: "updatedAt";
1924
+ fieldName: "runId";
1925
1925
  };
1926
1926
  };
1927
- runId: ConvexTextBuilderInitial<""> & {
1927
+ startedAt: ConvexNumberBuilderInitial<""> & {
1928
1928
  _: {
1929
1929
  notNull: true;
1930
1930
  };
@@ -1934,10 +1934,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1934
1934
  };
1935
1935
  } & {
1936
1936
  _: {
1937
- fieldName: "runId";
1937
+ fieldName: "startedAt";
1938
1938
  };
1939
1939
  };
1940
- startedAt: ConvexNumberBuilderInitial<""> & {
1940
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1941
1941
  _: {
1942
1942
  notNull: true;
1943
1943
  };
@@ -1947,7 +1947,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1947
1947
  };
1948
1948
  } & {
1949
1949
  _: {
1950
- fieldName: "startedAt";
1950
+ fieldName: "updatedAt";
1951
1951
  };
1952
1952
  };
1953
1953
  completedAt: ConvexNumberBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",