kitcn 0.31.0 → 0.31.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,32 @@
1
1
  # kitcn
2
2
 
3
+ ## 0.31.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#424](https://github.com/udecode/kitcn/pull/424) [`0e3a221`](https://github.com/udecode/kitcn/commit/0e3a2214e8e1037b323e603f19c2df89b0d95602) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
8
+
9
+ - Stop `aggregateBackfill` rewriting the stored state it is about to delete.
10
+ Clearing a `rankIndex` walked the btree once per member — a root-to-leaf
11
+ descent plus a patch on every node along the way — and then dropped the whole
12
+ tree regardless, so all of that work was thrown away. Clearing an
13
+ `aggregateIndex` did the same thing with buckets, decrementing each one down to
14
+ zero before deleting it. Both now delete their member rows outright and let the
15
+ existing tree and bucket sweeps reclaim the rest. Clearing 120 rank members
16
+ across three partitions went from 201 btree node writes to 15, one per node.
17
+ - Fix a `rankIndex` clear crashing with `Unexpected field 'deletionStack'` once a
18
+ partition holds more than a few hundred rows. The rank storage tables now
19
+ reuse the same definitions the btree writes to, so a large tree can persist its
20
+ traversal state and resume across mutations. Run
21
+ `npx convex dev` (or your usual codegen) to pick the schema up.
22
+ - Report real work from a clear chunk instead of a fixed guess, so
23
+ `aggregateBackfill --batch-size` now bounds a clear by the documents it
24
+ actually touches. Multi-partition rank indexes no longer schedule far more
25
+ chunks than the remaining work needs.
26
+ - Allow an app to declare `aggregateStorageTables` from `kitcn/aggregate`
27
+ alongside a table that also declares a `rankIndex`. `defineSchema` used to
28
+ reject that combination as a duplicate table name.
29
+
3
30
  ## 0.31.0
4
31
 
5
32
  ### Minor Changes
@@ -1,5 +1,5 @@
1
- import { Vn as ConvexTextBuilderInitial, Zt as ConvexTableWithColumns } from "../capabilities-DPB-JKlm.js";
2
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-Dddhscyy.js";
1
+ import { Vn as ConvexTextBuilderInitial, Zt as ConvexTableWithColumns } from "../capabilities-CG-oIMyR.js";
2
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-Bgkzm3Y-.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";
@@ -136,6 +136,10 @@ declare const aggregateStorageTables: {
136
136
  //#endregion
137
137
  //#region src/aggregate-core/btree.d.ts
138
138
  type Key$2 = Value;
139
+ type DeleteTreesResult = {
140
+ /** True once this aggregate owns no tree row at all. */done: boolean; /** Documents this call wrote, so callers can charge a real work budget. */
141
+ documents: number;
142
+ };
139
143
  //#endregion
140
144
  //#region src/aggregate-core/positions.d.ts
141
145
  type Bound$1<K extends Key$2, ID extends string> = {
@@ -240,11 +244,12 @@ declare class Aggregate<K extends Key, ID extends string, TNamespace extends Val
240
244
  rootLazy?: boolean;
241
245
  }, TNamespace>): Promise<void>;
242
246
  /**
243
- * Deletes up to `limit` namespace trees without recreating them. Returns true
244
- * once this aggregate owns no trees, so callers can drain every namespace
245
- * across several mutations instead of walking them all in one.
247
+ * Deletes up to `limit` nodes from one namespace tree without recreating it,
248
+ * reporting `done` once this aggregate owns no trees and how many documents
249
+ * the call wrote. Callers drain every namespace across several mutations
250
+ * instead of walking them all in one, and charge their budget by `documents`.
246
251
  */
247
- deleteTrees(ctx: RunMutationCtx, limit: number): Promise<boolean>;
252
+ deleteTrees(ctx: RunMutationCtx, limit: number): Promise<DeleteTreesResult>;
248
253
  makeRootLazy(ctx: RunMutationCtx, namespace: TNamespace): Promise<void>;
249
254
  paginateNamespaces(ctx: RunQueryCtx, cursor?: string, pageSize?: number): Promise<{
250
255
  cursor: string;
@@ -1,4 +1,5 @@
1
- import { n as TableAggregate$1, r as aggregateStorageTables, t as DirectAggregate$1 } from "../runtime-BcvcfaP8.js";
1
+ import { n as TableAggregate$1, t as DirectAggregate$1 } from "../runtime-B-8HKSIE.js";
2
+ import { i as aggregateStorageTables } from "../schema-BFP_awgP.js";
2
3
 
3
4
  //#region src/aggregate/index.ts
4
5
  const wrapTriggerFactory = (methodName, factory) => ((...args) => {
@@ -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-CTUQ9nxL.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-BKvk4lFx.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-CTUQ9nxL.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-BKvk4lFx.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";
@@ -109,31 +109,31 @@ type AdapterPaginationOptions = PaginationOptions & {
109
109
  };
110
110
  declare const adapterWhereValidator: convex_values0.VObject<{
111
111
  mode?: "sensitive" | "insensitive" | undefined;
112
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
113
112
  connector?: "AND" | "OR" | undefined;
113
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
114
114
  value: string | number | boolean | string[] | number[] | null;
115
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
- 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>;
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" | "operator" | "value" | "field" | "connector">;
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
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
128
126
  connector?: "AND" | "OR" | undefined;
127
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
129
128
  value: string | number | boolean | string[] | number[] | null;
130
129
  field: string;
131
130
  }[] | undefined;
132
- select?: string[] | undefined;
131
+ limit?: number | undefined;
133
132
  offset?: number | undefined;
133
+ select?: string[] | undefined;
134
134
  sortBy?: {
135
- field: string;
136
135
  direction: "asc" | "desc";
136
+ field: string;
137
137
  } | undefined;
138
138
  model: string;
139
139
  }, {
@@ -142,32 +142,32 @@ 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
- field: string;
146
145
  direction: "asc" | "desc";
146
+ field: string;
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", "field" | "direction">;
150
+ }, "optional", "direction" | "field">;
151
151
  where: convex_values0.VArray<{
152
152
  mode?: "sensitive" | "insensitive" | undefined;
153
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
154
153
  connector?: "AND" | "OR" | undefined;
154
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
155
155
  value: string | number | boolean | string[] | number[] | null;
156
156
  field: string;
157
157
  }[] | undefined, convex_values0.VObject<{
158
158
  mode?: "sensitive" | "insensitive" | undefined;
159
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
160
159
  connector?: "AND" | "OR" | undefined;
160
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
161
161
  value: string | number | boolean | string[] | number[] | null;
162
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
- 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>;
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" | "operator" | "value" | "field" | "connector">, "optional">;
170
- }, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
169
+ }, "required", "mode" | "value" | "connector" | "field" | "operator">, "optional">;
170
+ }, "required", "model" | "where" | "limit" | "offset" | "select" | "sortBy" | "sortBy.direction" | "sortBy.field">;
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;
@@ -2341,12 +2341,16 @@ type ClearIndexChunkResult = {
2341
2341
  * reports whether anything is left. Callers drive it to completion across
2342
2342
  * transactions, so clearing a large index never has to fit in one mutation.
2343
2343
  *
2344
- * Members are removed through the normal delta machinery rather than raw
2345
- * deletes, so buckets and extrema stay consistent with the members that remain
2346
- * at every intermediate step. That keeps concurrent writers correct while the
2347
- * clear drains. Residual bucket/extrema rows (drift with no member behind them)
2348
- * are swept only once no members are left, and the loop re-checks members
2349
- * afterwards.
2344
+ * Member rows are deleted outright rather than run back through the delta
2345
+ * machinery. The bucket and extrema branches below drop every row this index
2346
+ * owns whatever it holds, so folding a removal delta into a bucket first would
2347
+ * only rewrite a document this same clear is about to delete.
2348
+ *
2349
+ * Branch order is load-bearing: buckets and extrema are swept only once no
2350
+ * members are left, and the loop re-checks members afterwards. The intermediate
2351
+ * "members gone, buckets still populated" state is safe because `setCountState`
2352
+ * refuses to leave CLEARING while a bucket or extrema row survives, and the
2353
+ * CLEARING write barrier keeps concurrent writers out of the index.
2350
2354
  */
2351
2355
  declare const clearCountIndexChunk: (db: GenericDatabaseWriter<any>, tableName: string, indexName: string, batchSize: number) => Promise<ClearIndexChunkResult>;
2352
2356
  declare const listCountStates: (db: GenericDatabaseReader<any> | GenericDatabaseWriter<any>) => Promise<CountState[]>;
@@ -2392,10 +2396,20 @@ declare const ensureRankAllowedForRls: (tableConfig: TableRelationalConfig, rlsM
2392
2396
  declare const compileRankPlan: (tableConfig: TableRelationalConfig, indexName: string, where: unknown) => RankQueryPlan;
2393
2397
  declare const ensureRankIndexReady: (db: GenericDatabaseReader<any> | GenericDatabaseWriter<any>, tableName: string, indexName: string) => Promise<void>;
2394
2398
  /**
2395
- * Removes at most `batchSize` rank members and reports whether anything is
2396
- * left. Each member is removed from the btree before its row is dropped, so the
2397
- * tree stays consistent with the members that remain and a partially drained
2398
- * clear can safely resume in a later mutation.
2399
+ * Removes at most `batchSize` documents of a rank index's stored state and
2400
+ * reports whether anything is left. Callers drive it to completion across
2401
+ * transactions, so clearing a large index never has to fit in one mutation.
2402
+ *
2403
+ * Member rows are dropped without touching the btree. The tree branch below
2404
+ * deletes every node whatever it contains, so removing a member key first would
2405
+ * only buy a root-to-leaf descent plus an aggregate patch per level on nodes
2406
+ * this same clear is about to delete.
2407
+ *
2408
+ * Branch order is load-bearing: a member delete recreates the tree it lands on,
2409
+ * so the members must be gone before the first node is dropped. The
2410
+ * intermediate "members gone, tree still full" state is safe because
2411
+ * `setCountState` refuses to leave CLEARING while a tree row survives, and the
2412
+ * CLEARING write barrier keeps concurrent writers out of the index.
2399
2413
  */
2400
2414
  declare const clearRankIndexChunk: (db: GenericDatabaseWriter<any>, tableName: string, indexName: string, batchSize: number) => Promise<{
2401
2415
  done: boolean;
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-DGSkmXQk.mjs";
2
+ import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-CYYSNf_o.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import fs, { existsSync, readFileSync } from "node:fs";
5
5
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
@@ -199,8 +199,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
199
199
  count: convex_server0.RegisteredQuery<"internal", {
200
200
  where?: {
201
201
  mode?: "sensitive" | "insensitive" | undefined;
202
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
203
202
  connector?: "AND" | "OR" | undefined;
203
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
204
204
  value: string | number | boolean | string[] | number[] | null;
205
205
  field: string;
206
206
  }[] | undefined;
@@ -209,8 +209,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
209
209
  consumeOne: convex_server0.RegisteredMutation<"internal", {
210
210
  input: {
211
211
  where?: {
212
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
213
212
  connector?: "AND" | "OR" | undefined;
213
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
214
214
  value: string | number | boolean | string[] | number[] | null;
215
215
  field: string;
216
216
  }[] | undefined;
@@ -235,18 +235,10 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
235
235
  };
236
236
  }, Promise<any>>;
237
237
  deleteMany: convex_server0.RegisteredMutation<"internal", {
238
- paginationOpts: {
239
- id?: number;
240
- endCursor?: string | null;
241
- maximumRowsRead?: number;
242
- maximumBytesRead?: number;
243
- numItems: number;
244
- cursor: string | null;
245
- };
246
238
  input: {
247
239
  where?: {
248
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
249
240
  connector?: "AND" | "OR" | undefined;
241
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
250
242
  value: string | number | boolean | string[] | number[] | null;
251
243
  field: string;
252
244
  }[] | undefined;
@@ -255,6 +247,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
255
247
  where?: any[] | undefined;
256
248
  model: string;
257
249
  };
250
+ paginationOpts: {
251
+ id?: number;
252
+ endCursor?: string | null;
253
+ maximumRowsRead?: number;
254
+ maximumBytesRead?: number;
255
+ numItems: number;
256
+ cursor: string | null;
257
+ };
258
258
  }, Promise<{
259
259
  count: number;
260
260
  ids: any[];
@@ -266,8 +266,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
266
266
  deleteOne: convex_server0.RegisteredMutation<"internal", {
267
267
  input: {
268
268
  where?: {
269
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
270
269
  connector?: "AND" | "OR" | undefined;
270
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
271
271
  value: string | number | boolean | string[] | number[] | null;
272
272
  field: string;
273
273
  }[] | undefined;
@@ -278,20 +278,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
278
278
  };
279
279
  }, Promise<Record<string, unknown> | undefined>>;
280
280
  findMany: convex_server0.RegisteredQuery<"internal", {
281
- limit?: number | undefined;
282
281
  join?: any;
283
282
  where?: {
284
283
  mode?: "sensitive" | "insensitive" | undefined;
285
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
286
284
  connector?: "AND" | "OR" | undefined;
285
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
287
286
  value: string | number | boolean | string[] | number[] | null;
288
287
  field: string;
289
288
  }[] | undefined;
289
+ limit?: number | undefined;
290
290
  offset?: number | undefined;
291
291
  sortBy?: {
292
- field: string;
293
292
  direction: "asc" | "desc";
293
+ field: string;
294
294
  } | undefined;
295
+ model: string;
295
296
  paginationOpts: {
296
297
  id?: number;
297
298
  endCursor?: string | null;
@@ -300,14 +301,13 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
300
301
  numItems: number;
301
302
  cursor: string | null;
302
303
  };
303
- model: string;
304
304
  }, Promise<PaginationResult<convex_server0.GenericDocument>>>;
305
305
  findOne: convex_server0.RegisteredQuery<"internal", {
306
306
  join?: any;
307
307
  where?: {
308
308
  mode?: "sensitive" | "insensitive" | undefined;
309
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
310
309
  connector?: "AND" | "OR" | undefined;
310
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
311
311
  value: string | number | boolean | string[] | number[] | null;
312
312
  field: string;
313
313
  }[] | undefined;
@@ -319,8 +319,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
319
319
  input: {
320
320
  where?: {
321
321
  mode?: "sensitive" | "insensitive" | undefined;
322
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
323
322
  connector?: "AND" | "OR" | undefined;
323
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
324
324
  value: string | number | boolean | string[] | number[] | null;
325
325
  field: string;
326
326
  }[] | undefined;
@@ -331,31 +331,31 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
331
331
  }, Promise<any>>;
332
332
  rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
333
333
  updateMany: convex_server0.RegisteredMutation<"internal", {
334
- paginationOpts: {
335
- id?: number;
336
- endCursor?: string | null;
337
- maximumRowsRead?: number;
338
- maximumBytesRead?: number;
339
- numItems: number;
340
- cursor: string | null;
341
- };
342
334
  input: {
343
335
  where?: {
344
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
345
336
  connector?: "AND" | "OR" | undefined;
337
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
346
338
  value: string | number | boolean | string[] | number[] | null;
347
339
  field: string;
348
340
  }[] | undefined;
341
+ model: string;
349
342
  update: {
350
343
  [x: string]: unknown;
351
344
  [x: number]: unknown;
352
345
  [x: symbol]: unknown;
353
346
  };
354
- model: string;
355
347
  } | {
356
348
  where?: any[] | undefined;
357
- update: any;
358
349
  model: string;
350
+ update: any;
351
+ };
352
+ paginationOpts: {
353
+ id?: number;
354
+ endCursor?: string | null;
355
+ maximumRowsRead?: number;
356
+ maximumBytesRead?: number;
357
+ numItems: number;
358
+ cursor: string | null;
359
359
  };
360
360
  }, Promise<{
361
361
  count: number;
@@ -368,21 +368,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
368
368
  updateOne: convex_server0.RegisteredMutation<"internal", {
369
369
  input: {
370
370
  where?: {
371
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
372
371
  connector?: "AND" | "OR" | undefined;
372
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
373
373
  value: string | number | boolean | string[] | number[] | null;
374
374
  field: string;
375
375
  }[] | undefined;
376
+ model: string;
376
377
  update: {
377
378
  [x: string]: unknown;
378
379
  [x: number]: unknown;
379
380
  [x: symbol]: unknown;
380
381
  };
381
- model: string;
382
382
  } | {
383
383
  where?: any[] | undefined;
384
- update: any;
385
384
  model: string;
385
+ update: any;
386
386
  };
387
387
  }, Promise<any>>;
388
388
  };
@@ -937,58 +937,6 @@ function text(name) {
937
937
  return new ConvexTextBuilder(name ?? "");
938
938
  }
939
939
 
940
- //#endregion
941
- //#region src/orm/extensions.ts
942
- function defineChainMethod(target, key, value) {
943
- Object.defineProperty(target, key, {
944
- value,
945
- enumerable: false,
946
- configurable: true
947
- });
948
- }
949
- function createSchemaExtensionChain(state, capabilities) {
950
- const extension = {
951
- key: state.key,
952
- tables: state.tables
953
- };
954
- Object.defineProperty(extension, OrmSchemaExtensionRelations, {
955
- value: state.relations,
956
- enumerable: false,
957
- configurable: true
958
- });
959
- Object.defineProperty(extension, OrmSchemaExtensionTriggers, {
960
- value: state.triggers,
961
- enumerable: false,
962
- configurable: true
963
- });
964
- if (capabilities.canRelations) defineChainMethod(extension, "relations", (relations) => createSchemaExtensionChain({
965
- ...state,
966
- relations
967
- }, {
968
- canRelations: false,
969
- canTriggers: true
970
- }));
971
- if (capabilities.canTriggers) defineChainMethod(extension, "triggers", (triggers) => createSchemaExtensionChain({
972
- ...state,
973
- triggers
974
- }, {
975
- canRelations: false,
976
- canTriggers: false
977
- }));
978
- return extension;
979
- }
980
- function defineSchemaExtension(key, tables) {
981
- return createSchemaExtensionChain({
982
- key,
983
- tables,
984
- relations: void 0,
985
- triggers: void 0
986
- }, {
987
- canRelations: true,
988
- canTriggers: true
989
- });
990
- }
991
-
992
940
  //#endregion
993
941
  //#region src/orm/indexes.ts
994
942
  var ConvexIndexBuilderOn = class {
@@ -1961,14 +1909,98 @@ const convexTableWithRLS = (name, columns, extraConfig) => {
1961
1909
  };
1962
1910
  const convexTable = Object.assign(convexTableInternal, { withRLS: convexTableWithRLS });
1963
1911
 
1912
+ //#endregion
1913
+ //#region src/aggregate-core/schema.ts
1914
+ const AGGREGATE_TREE_TABLE = "aggregate_rank_tree";
1915
+ const AGGREGATE_NODE_TABLE = "aggregate_rank_node";
1916
+ const aggregateCounterValidator = v.object({
1917
+ count: v.number(),
1918
+ sum: v.number()
1919
+ });
1920
+ const aggregateItemValidator = v.object({
1921
+ k: v.any(),
1922
+ v: v.any(),
1923
+ s: v.number()
1924
+ });
1925
+ const aggregateTreeTable = convexTable(AGGREGATE_TREE_TABLE, {
1926
+ aggregateName: text().notNull(),
1927
+ deletionStack: custom(v.array(v.id(AGGREGATE_NODE_TABLE))),
1928
+ maxNodeSize: integer().notNull(),
1929
+ namespace: custom(v.any()),
1930
+ root: id(AGGREGATE_NODE_TABLE).notNull()
1931
+ }, (tree) => [index("by_namespace").on(tree.namespace), index("by_aggregate_name").on(tree.aggregateName)]);
1932
+ const aggregateNodeTable = convexTable(AGGREGATE_NODE_TABLE, {
1933
+ aggregate: custom(aggregateCounterValidator),
1934
+ items: custom(v.array(aggregateItemValidator)).notNull(),
1935
+ subtrees: custom(v.array(v.string())).notNull()
1936
+ });
1937
+ const aggregateStorageTables$1 = {
1938
+ [AGGREGATE_NODE_TABLE]: aggregateNodeTable,
1939
+ [AGGREGATE_TREE_TABLE]: aggregateTreeTable
1940
+ };
1941
+
1942
+ //#endregion
1943
+ //#region src/orm/extensions.ts
1944
+ function defineChainMethod(target, key, value) {
1945
+ Object.defineProperty(target, key, {
1946
+ value,
1947
+ enumerable: false,
1948
+ configurable: true
1949
+ });
1950
+ }
1951
+ function createSchemaExtensionChain(state, capabilities) {
1952
+ const extension = {
1953
+ key: state.key,
1954
+ tables: state.tables
1955
+ };
1956
+ Object.defineProperty(extension, OrmSchemaExtensionRelations, {
1957
+ value: state.relations,
1958
+ enumerable: false,
1959
+ configurable: true
1960
+ });
1961
+ Object.defineProperty(extension, OrmSchemaExtensionTriggers, {
1962
+ value: state.triggers,
1963
+ enumerable: false,
1964
+ configurable: true
1965
+ });
1966
+ if (capabilities.canRelations) defineChainMethod(extension, "relations", (relations) => createSchemaExtensionChain({
1967
+ ...state,
1968
+ relations
1969
+ }, {
1970
+ canRelations: false,
1971
+ canTriggers: true
1972
+ }));
1973
+ if (capabilities.canTriggers) defineChainMethod(extension, "triggers", (triggers) => createSchemaExtensionChain({
1974
+ ...state,
1975
+ triggers
1976
+ }, {
1977
+ canRelations: false,
1978
+ canTriggers: false
1979
+ }));
1980
+ return extension;
1981
+ }
1982
+ function defineSchemaExtension(key, tables) {
1983
+ return createSchemaExtensionChain({
1984
+ key,
1985
+ tables,
1986
+ relations: void 0,
1987
+ triggers: void 0
1988
+ }, {
1989
+ canRelations: true,
1990
+ canTriggers: true
1991
+ });
1992
+ }
1993
+
1964
1994
  //#endregion
1965
1995
  //#region src/orm/aggregate-index/schema.ts
1966
1996
  const AGGREGATE_BUCKET_TABLE = "aggregate_bucket";
1967
1997
  const AGGREGATE_MEMBER_TABLE = "aggregate_member";
1968
1998
  const AGGREGATE_EXTREMA_TABLE = "aggregate_extrema";
1969
- const AGGREGATE_RANK_TREE_TABLE = "aggregate_rank_tree";
1970
- const AGGREGATE_RANK_NODE_TABLE = "aggregate_rank_node";
1971
1999
  const AGGREGATE_STATE_TABLE = "aggregate_state";
2000
+ const AGGREGATE_RANK_TREE_TABLE = AGGREGATE_TREE_TABLE;
2001
+ const AGGREGATE_RANK_NODE_TABLE = AGGREGATE_NODE_TABLE;
2002
+ const rankTreeTable = aggregateTreeTable;
2003
+ const rankNodeTable = aggregateNodeTable;
1972
2004
  const countBucketTable = convexTable(AGGREGATE_BUCKET_TABLE, {
1973
2005
  tableKey: text().notNull(),
1974
2006
  indexName: text().notNull(),
@@ -2027,24 +2059,6 @@ const countStateTable = convexTable(AGGREGATE_STATE_TABLE, {
2027
2059
  index("by_kind_status").on(t.kind, t.status),
2028
2060
  index("by_table_status").on(t.tableKey, t.status)
2029
2061
  ]);
2030
- const rankTreeTable = convexTable(AGGREGATE_RANK_TREE_TABLE, {
2031
- aggregateName: text().notNull(),
2032
- maxNodeSize: integer().notNull(),
2033
- namespace: json(),
2034
- root: id(AGGREGATE_RANK_NODE_TABLE).notNull()
2035
- }, (tree) => [index("by_namespace").on(tree.namespace), index("by_aggregate_name").on(tree.aggregateName)]);
2036
- const rankNodeTable = convexTable(AGGREGATE_RANK_NODE_TABLE, {
2037
- aggregate: objectOf({
2038
- count: integer().notNull(),
2039
- sum: integer().notNull()
2040
- }),
2041
- items: arrayOf(objectOf({
2042
- k: json(),
2043
- v: json(),
2044
- s: integer().notNull()
2045
- })).notNull(),
2046
- subtrees: arrayOf(text().notNull()).notNull()
2047
- });
2048
2062
  const aggregateStorageTables = {
2049
2063
  [AGGREGATE_BUCKET_TABLE]: countBucketTable,
2050
2064
  [AGGREGATE_MEMBER_TABLE]: countMemberTable,
@@ -1,4 +1,4 @@
1
- import { $ as RankIndexDefinition, G as CountBackfillChunkArgs, J as CountBackfillStatusArgs, K as CountBackfillKickoffArgs, Q as CountIndexDefinition, X as CountQueryPlan, Y as AggregateQueryPlan, Z as AggregateIndexDefinition, et as RankOrderField, q as CountBackfillMode, r as OrmCapability } from "../../capabilities-DPB-JKlm.js";
1
+ import { $ as RankIndexDefinition, G as CountBackfillChunkArgs, J as CountBackfillStatusArgs, K as CountBackfillKickoffArgs, Q as CountIndexDefinition, X as CountQueryPlan, Y as AggregateQueryPlan, Z as AggregateIndexDefinition, et as RankOrderField, q as CountBackfillMode, r as OrmCapability } from "../../capabilities-CG-oIMyR.js";
2
2
 
3
3
  //#region src/orm/aggregate-index/capability.d.ts
4
4
  /**