kitcn 0.28.1 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # kitcn
2
2
 
3
+ ## 0.29.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#421](https://github.com/udecode/kitcn/pull/421) [`26dd9b5`](https://github.com/udecode/kitcn/commit/26dd9b55357e4d49b7ada84812fefd52648f304a) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Breaking changes
8
+
9
+ - Register `migrationStatus` and `aggregateBackfillStatus` as internal
10
+ **queries** instead of internal mutations. Polling migration or aggregate
11
+ status no longer opens a write transaction, so a status monitor stops
12
+ competing for OCC write slots on the very tables it is reporting on. Both can
13
+ now back a live subscription, and neither can be scheduled any more.
14
+
15
+ ```ts
16
+ // Before — status read had to run from a mutation context
17
+ export const getStatus = authMutation.mutation(async ({ ctx }) => {
18
+ const server = createServerCaller(ctx);
19
+ return await server.migrationStatus({});
20
+ });
21
+
22
+ // After — status reads from a query context
23
+ export const getStatus = authQuery.query(async ({ ctx }) => {
24
+ const server = createServerCaller(ctx);
25
+ return await server.migrationStatus({});
26
+ });
27
+ ```
28
+
29
+ - Accept an `internalQuery` builder in `createOrm(...)` alongside
30
+ `internalMutation`. Apps generated by `kitcn codegen` pass it automatically;
31
+ hand-written `createOrm` calls that use `orm.api()` should pass it too so the
32
+ status procedures are built with the app's own Convex builder.
33
+
34
+ ```ts
35
+ // Before
36
+ const orm = createOrm({ schema, ormFunctions, internalMutation });
37
+
38
+ // After
39
+ const orm = createOrm({
40
+ schema,
41
+ ormFunctions,
42
+ internalMutation,
43
+ internalQuery,
44
+ });
45
+ ```
46
+
47
+ ## Patches
48
+
49
+ - Fix `migrationStatus` reading the entire `migration_run` history to return the
50
+ most recent runs. The listing now walks a new `by_started_at` index in reverse
51
+ and stops at `limit`, so the cost of a status call no longer grows with the
52
+ number of migrations ever run. Runs that share a `startedAt` millisecond now
53
+ order newest-first.
54
+ - Bound the `limit` argument of `migrationStatus` at `MAX_STATUS_RUN_LIMIT`
55
+ (`100`, default `25`), exported from `kitcn/orm/migrations`, so a caller
56
+ cannot reintroduce an unbounded read through the args.
57
+ - Resolve `migrationStatus`'s `runId` and `activeRun` through their existing
58
+ indexes instead of scanning the run history. `activeRun` now agrees with the
59
+ run that `migrate cancel` targets.
60
+
3
61
  ## 0.28.1
4
62
 
5
63
  ### Patch Changes
@@ -1,5 +1,5 @@
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";
1
+ import { Vn as ConvexTextBuilderInitial, Zt as ConvexTableWithColumns } from "../capabilities-6PZBmvc8.js";
2
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-CX5-0M5p.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-BBCcpNyF.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-CgYQZCw2.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-BBCcpNyF.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-CgYQZCw2.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,22 +111,22 @@ 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
- value: string | number | boolean | string[] | number[] | null;
115
114
  field: string;
115
+ value: string | number | boolean | string[] | number[] | null;
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" | "value" | "connector" | "field" | "operator">;
122
+ }, "required", "mode" | "connector" | "field" | "operator" | "value">;
123
123
  declare const adapterArgsValidator: convex_values0.VObject<{
124
124
  where?: {
125
125
  mode?: "sensitive" | "insensitive" | undefined;
126
126
  connector?: "AND" | "OR" | undefined;
127
127
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
128
- value: string | number | boolean | string[] | number[] | null;
129
128
  field: string;
129
+ value: string | number | boolean | string[] | number[] | null;
130
130
  }[] | undefined;
131
131
  limit?: number | undefined;
132
132
  offset?: number | undefined;
@@ -152,21 +152,21 @@ 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
- value: string | number | boolean | string[] | number[] | null;
156
155
  field: string;
156
+ value: string | number | boolean | string[] | number[] | null;
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
- value: string | number | boolean | string[] | number[] | null;
162
161
  field: string;
162
+ value: string | number | boolean | string[] | number[] | null;
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" | "value" | "connector" | "field" | "operator">, "optional">;
169
+ }, "required", "mode" | "connector" | "field" | "operator" | "value">, "optional">;
170
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>;
@@ -3647,8 +3647,15 @@ declare function buildMigrationPlan<TSchema extends MigrationSchemaInput = Table
3647
3647
  to?: string;
3648
3648
  }): MigrationPlan<TSchema>;
3649
3649
  declare namespace runtime_d_exports {
3650
- export { MigrationCancelArgs, MigrationRunArgs, MigrationRunChunkArgs, MigrationStatusArgs, createMigrationHandlers };
3650
+ export { MAX_STATUS_RUN_LIMIT, MigrationCancelArgs, MigrationRunArgs, MigrationRunChunkArgs, MigrationStatusArgs, createMigrationHandlers };
3651
3651
  }
3652
+ /**
3653
+ * Hard ceiling on how many `migration_run` rows one `status()` call may read.
3654
+ *
3655
+ * `limit` is caller-supplied, so bounding the query without bounding the
3656
+ * argument would just move the unbounded read behind the args surface.
3657
+ */
3658
+ declare const MAX_STATUS_RUN_LIMIT = 100;
3652
3659
  type MigrationRunArgs = {
3653
3660
  direction?: MigrationDirection;
3654
3661
  steps?: number;
@@ -3673,6 +3680,13 @@ type RuntimeCtx = {
3673
3680
  db: GenericDatabaseWriter<any>;
3674
3681
  scheduler?: Scheduler;
3675
3682
  };
3683
+ /**
3684
+ * `status()` never writes, so it runs on a query ctx where `db` is a reader and
3685
+ * there is no scheduler.
3686
+ */
3687
+ type RuntimeReadCtx = {
3688
+ db: GenericDatabaseReader<any> | GenericDatabaseWriter<any>;
3689
+ };
3676
3690
  type CreateMigrationHandlersParams<TSchema extends TablesRelationalConfig> = {
3677
3691
  schema: TSchema;
3678
3692
  migrations?: MigrationSet<TSchema>;
@@ -3682,7 +3696,7 @@ type CreateMigrationHandlersParams<TSchema extends TablesRelationalConfig> = {
3682
3696
  declare function createMigrationHandlers<TSchema extends TablesRelationalConfig>(params: CreateMigrationHandlersParams<TSchema>): {
3683
3697
  run: (ctx: RuntimeCtx, args?: MigrationRunArgs) => Promise<Record<string, unknown>>;
3684
3698
  chunk: (ctx: RuntimeCtx, args: MigrationRunChunkArgs) => Promise<Record<string, unknown>>;
3685
- status: (ctx: RuntimeCtx, args?: MigrationStatusArgs) => Promise<Record<string, unknown>>;
3699
+ status: (ctx: RuntimeReadCtx, args?: MigrationStatusArgs) => Promise<Record<string, unknown>>;
3686
3700
  cancel: (ctx: RuntimeCtx, args?: MigrationCancelArgs) => Promise<Record<string, unknown>>;
3687
3701
  };
3688
3702
  //#endregion
@@ -3764,4 +3778,4 @@ type OrmCapabilities = {
3764
3778
  migrations?: OrmMigrationCapability;
3765
3779
  };
3766
3780
  //#endregion
3767
- export { RankOrderField as $, BinaryExpression as $n, OrmLifecycleOperation as $t, DatabaseWithMutations as A, ConvexCheckConfig as An, AnyColumn as Ar, VectorQueryConfig as At, RlsContext as B, ConvexTextBuilderInitial as Bn, IsUnique as Br, RelationsBuilderColumnConfig as Bt, MigrationTableName as C, aggregateIndex as Cn, notBetween as Cr, OrderDirection as Ct, defineMigrationSet as D, uniqueIndex as Dn, SystemFieldAliases as Dr, ReturningResult as Dt, defineMigration as E, searchIndex as En, startsWith as Er, ReturningAll as Et, DeleteMode as F, ConvexUniqueConstraintConfig as Fn, ColumnBuilderWithTableName as Fr, ExtractTablesWithRelations as Ft, CountBackfillKickoffArgs as G, OrmRuntimeDefaults as Gn, defineRelations as Gt, EdgeMetadata as H, ConvexColumnBuilder as Hn, entityKind as Hr, RelationsConfigWithSchema as Ht, SerializedFilterExpression as I, check as In, ColumnDataType as Ir, ManyConfig as It, AggregateQueryPlan as J, OrmSchemaExtensionTriggers as Jn, ConvexDeletionConfig as Jt, CountBackfillMode as K, OrmSchemaExtensionRelations as Kn, defineRelationsPart as Kt, getChecks as L, foreignKey as Ln, DrizzleEntity as Lr, OneConfig as Lt, OrmReader as M, ConvexForeignKeyConfig as Mn, ColumnBuilderBaseConfig as Mr, unsetToken as Mt, OrmWriter as N, ConvexUniqueConstraintBuilder as Nn, ColumnBuilderRuntimeConfig as Nr, AnyRelationsBuilderConfig as Nt, detectMigrationDrift as O, vectorIndex as On, SystemFields as Or, ReturningSelection as Ot, CascadeMode as P, ConvexUniqueConstraintBuilderOn as Pn, ColumnBuilderTypeConfig as Pr, ExtractTablesFromSchema as Pt, RankIndexDefinition as Q, TableName as Qn, OrmLifecycleChange as Qt, getForeignKeys as R, unique as Rn, HasDefault as Rr, RelationsBuilder as Rt, MigrationStep as S, ConvexVectorIndexConfig as Sn, not as Sr, OrderByClause as St, buildMigrationPlan as T, rankIndex as Tn, or as Tr, PredicateWhereIndexConfig as Tt, extractRelationsConfig as U, Brand as Un, TableRelationalConfig as Ut, RlsMode as V, text as Vn, NotNull as Vr, RelationsBuilderConfigValue as Vt, CountBackfillChunkArgs as W, Columns as Wn, TablesRelationalConfig as Wt, AggregateIndexDefinition as X, OrmSchemaRelations as Xn, ConvexTableWithColumns as Xt, CountQueryPlan as Y, OrmSchemaExtensions as Yn, ConvexTable as Yt, CountIndexDefinition as Z, OrmSchemaTriggers as Zn, DiscriminatorBuilderConfig as Zt, MigrationMigrateOne as _, ConvexSearchIndexBuilder as _n, isNull as _r, MutationPaginateConfig as _t, MigrationCancelArgs as a, RlsPolicyConfig as an, and as ar, CountConfig as at, MigrationSet as b, ConvexVectorIndexBuilder as bn, lte as br, MutationReturning as bt, MigrationStatusArgs as c, RlsRole as cn, endsWith as cr, FilterOperators as ct, MigrationDefinition as d, ConvexAggregateIndexBuilder as dn, gt as dr, InferModelFromColumns as dt, TableConfig as en, ExpressionVisitor as er, AggregateConfig as et, MigrationDirection as f, ConvexAggregateIndexBuilderOn as fn, gte as fr, InferSelectModel as ft, MigrationManifestEntry as g, ConvexRankIndexBuilderOn as gn, isNotNull as gr, MutationExecutionMode as gt, MigrationDriftIssue as h, ConvexRankIndexBuilder as hn, isFieldReference as hr, MutationExecuteResult as ht, OrmMigrationCapability as i, RlsPolicy as in, UnaryExpression as ir, BuildRelationResult as it, DatabaseWithQuery as j, ConvexForeignKeyBuilder as jn, ColumnBuilder as jr, VectorSearchProvider as jt, CreateDatabaseOptions as k, ConvexCheckBuilder as kn, $Type as kr, UpdateSet as kt, createMigrationHandlers as l, RlsRoleConfig as ln, eq as lr, GetColumnData as lt, MigrationDocContext as m, ConvexIndexBuilderOn as mn, inArray as mr, MutationExecuteConfig as mt, OrmCapabilities as n, deletion as nn, FilterExpression$1 as nr, AggregateResult as nt, MigrationRunArgs as o, RlsPolicyToOption as on, between as or, CountResult as ot, MigrationDoc as p, ConvexIndexBuilder as pn, ilike as pr, InsertValue as pt, CountBackfillStatusArgs as q, OrmSchemaExtensionTables as qn, ConvexDeletionBuilder as qt, OrmCapability as r, discriminator as rn, LogicalExpression as rr, BuildQueryResult as rt, MigrationRunChunkArgs as s, rlsPolicy as sn, contains as sr, DBQueryConfig as st, OrmAggregateCapability as t, convexTable as tn, FieldReference as tr, AggregateFieldValue as tt, MigrationAppliedState as u, rlsRole as un, fieldRef as ur, InferInsertModel as ut, MigrationPlan as v, ConvexSearchIndexBuilderOn as vn, like as vr, MutationPaginatedResult as vt, MigrationWriteMode as w, index as wn, notInArray as wr, PaginatedResult as wt, MigrationStateMap as x, ConvexVectorIndexBuilderOn as xn, ne as xr, MutationRunMode as xt, MigrationRunStatus as y, ConvexSearchIndexConfig as yn, lt as yr, MutationResult as yt, getUniqueIndexes as z, ConvexTextBuilder as zn, IsPrimaryKey as zr, RelationsBuilderColumnBase as zt };
3781
+ export { RankIndexDefinition as $, TableName as $n, OrmLifecycleChange as $t, CreateDatabaseOptions as A, ConvexCheckBuilder as An, $Type as Ar, UpdateSet as At, getUniqueIndexes as B, ConvexTextBuilder as Bn, IsPrimaryKey as Br, RelationsBuilderColumnBase as Bt, MigrationStep as C, ConvexVectorIndexConfig as Cn, not as Cr, OrderByClause as Ct, defineMigration as D, searchIndex as Dn, startsWith as Dr, ReturningAll as Dt, buildMigrationPlan as E, rankIndex as En, or as Er, PredicateWhereIndexConfig as Et, CascadeMode as F, ConvexUniqueConstraintBuilderOn as Fn, ColumnBuilderTypeConfig as Fr, ExtractTablesFromSchema as Ft, CountBackfillChunkArgs as G, Columns as Gn, TablesRelationalConfig as Gt, RlsMode as H, text as Hn, NotNull as Hr, RelationsBuilderConfigValue as Ht, DeleteMode as I, ConvexUniqueConstraintConfig as In, ColumnBuilderWithTableName as Ir, ExtractTablesWithRelations as It, CountBackfillStatusArgs as J, OrmSchemaExtensionTables as Jn, ConvexDeletionBuilder as Jt, CountBackfillKickoffArgs as K, OrmRuntimeDefaults as Kn, defineRelations as Kt, SerializedFilterExpression as L, check as Ln, ColumnDataType as Lr, ManyConfig as Lt, DatabaseWithQuery as M, ConvexForeignKeyBuilder as Mn, ColumnBuilder as Mr, VectorSearchProvider as Mt, OrmReader as N, ConvexForeignKeyConfig as Nn, ColumnBuilderBaseConfig as Nr, unsetToken as Nt, defineMigrationSet as O, uniqueIndex as On, SystemFieldAliases as Or, ReturningResult as Ot, OrmWriter as P, ConvexUniqueConstraintBuilder as Pn, ColumnBuilderRuntimeConfig as Pr, AnyRelationsBuilderConfig as Pt, CountIndexDefinition as Q, OrmSchemaTriggers as Qn, DiscriminatorBuilderConfig as Qt, getChecks as R, foreignKey as Rn, DrizzleEntity as Rr, OneConfig as Rt, MigrationStateMap as S, ConvexVectorIndexBuilderOn as Sn, ne as Sr, MutationRunMode as St, MigrationWriteMode as T, index as Tn, notInArray as Tr, PaginatedResult as Tt, EdgeMetadata as U, ConvexColumnBuilder as Un, entityKind as Ur, RelationsConfigWithSchema as Ut, RlsContext as V, ConvexTextBuilderInitial as Vn, IsUnique as Vr, RelationsBuilderColumnConfig as Vt, extractRelationsConfig as W, Brand as Wn, TableRelationalConfig as Wt, CountQueryPlan as X, OrmSchemaExtensions as Xn, ConvexTable as Xt, AggregateQueryPlan as Y, OrmSchemaExtensionTriggers as Yn, ConvexDeletionConfig as Yt, AggregateIndexDefinition as Z, OrmSchemaRelations as Zn, ConvexTableWithColumns as Zt, MigrationManifestEntry as _, ConvexRankIndexBuilderOn as _n, isNotNull as _r, MutationExecutionMode as _t, MAX_STATUS_RUN_LIMIT as a, RlsPolicy as an, UnaryExpression as ar, BuildRelationResult as at, MigrationRunStatus as b, ConvexSearchIndexConfig as bn, lt as br, MutationResult as bt, MigrationRunChunkArgs as c, rlsPolicy as cn, contains as cr, DBQueryConfig as ct, MigrationAppliedState as d, rlsRole as dn, fieldRef as dr, InferInsertModel as dt, OrmLifecycleOperation as en, BinaryExpression as er, RankOrderField as et, MigrationDefinition as f, ConvexAggregateIndexBuilder as fn, gt as fr, InferModelFromColumns as ft, MigrationDriftIssue as g, ConvexRankIndexBuilder as gn, isFieldReference as gr, MutationExecuteResult as gt, MigrationDocContext as h, ConvexIndexBuilderOn as hn, inArray as hr, MutationExecuteConfig as ht, OrmMigrationCapability as i, discriminator as in, LogicalExpression as ir, BuildQueryResult as it, DatabaseWithMutations as j, ConvexCheckConfig as jn, AnyColumn as jr, VectorQueryConfig as jt, detectMigrationDrift as k, vectorIndex as kn, SystemFields as kr, ReturningSelection as kt, MigrationStatusArgs as l, RlsRole as ln, endsWith as lr, FilterOperators as lt, MigrationDoc as m, ConvexIndexBuilder as mn, ilike as mr, InsertValue as mt, OrmCapabilities as n, convexTable as nn, FieldReference as nr, AggregateFieldValue as nt, MigrationCancelArgs as o, RlsPolicyConfig as on, and as or, CountConfig as ot, MigrationDirection as p, ConvexAggregateIndexBuilderOn as pn, gte as pr, InferSelectModel as pt, CountBackfillMode as q, OrmSchemaExtensionRelations as qn, defineRelationsPart as qt, OrmCapability as r, deletion as rn, FilterExpression$1 as rr, AggregateResult as rt, MigrationRunArgs as s, RlsPolicyToOption as sn, between as sr, CountResult as st, OrmAggregateCapability as t, TableConfig as tn, ExpressionVisitor as tr, AggregateConfig as tt, createMigrationHandlers as u, RlsRoleConfig as un, eq as ur, GetColumnData as ut, MigrationMigrateOne as v, ConvexSearchIndexBuilder as vn, isNull as vr, MutationPaginateConfig as vt, MigrationTableName as w, aggregateIndex as wn, notBetween as wr, OrderDirection as wt, MigrationSet as x, ConvexVectorIndexBuilder as xn, lte as xr, MutationReturning as xt, MigrationPlan as y, ConvexSearchIndexBuilderOn as yn, like as yr, MutationPaginatedResult as yt, getForeignKeys as z, unique as zn, HasDefault as zr, RelationsBuilder as zt };
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-Z8jj6ecD.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-Dk8RJvt5.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";
@@ -64,7 +64,11 @@ const migrationRunTable = convexTable(MIGRATION_RUN_TABLE, {
64
64
  completedAt: integer(),
65
65
  cancelRequested: boolean().notNull(),
66
66
  lastError: text()
67
- }, (t) => [index("by_run_id").on(t.runId), index("by_status").on(t.status)]);
67
+ }, (t) => [
68
+ index("by_run_id").on(t.runId),
69
+ index("by_status").on(t.status),
70
+ index("by_started_at").on(t.startedAt)
71
+ ]);
68
72
  const migrationStorageTables = {
69
73
  [MIGRATION_STATE_TABLE]: migrationStateTable,
70
74
  [MIGRATION_RUN_TABLE]: migrationRunTable
@@ -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
- value: string | number | boolean | string[] | number[] | null;
187
186
  field: string;
187
+ value: string | number | boolean | string[] | number[] | null;
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
- value: string | number | boolean | string[] | number[] | null;
215
214
  field: string;
215
+ value: string | number | boolean | string[] | number[] | null;
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
- value: string | number | boolean | string[] | number[] | null;
244
243
  field: string;
244
+ value: string | number | boolean | string[] | number[] | null;
245
245
  }[] | undefined;
246
246
  model: string;
247
247
  } | {
@@ -255,8 +255,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
255
255
  mode?: "sensitive" | "insensitive" | undefined;
256
256
  connector?: "AND" | "OR" | undefined;
257
257
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
258
- value: string | number | boolean | string[] | number[] | null;
259
258
  field: string;
259
+ value: string | number | boolean | string[] | number[] | null;
260
260
  }[] | undefined;
261
261
  limit?: number | undefined;
262
262
  offset?: number | undefined;
@@ -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
- value: string | number | boolean | string[] | number[] | null;
284
283
  field: string;
284
+ value: string | number | boolean | string[] | number[] | null;
285
285
  }[] | undefined;
286
286
  select?: string[] | undefined;
287
287
  model: string;
@@ -293,8 +293,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
293
293
  mode?: "sensitive" | "insensitive" | undefined;
294
294
  connector?: "AND" | "OR" | undefined;
295
295
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
296
- value: string | number | boolean | string[] | number[] | null;
297
296
  field: string;
297
+ value: string | number | boolean | string[] | number[] | null;
298
298
  }[] | undefined;
299
299
  set?: Record<string, any> | undefined;
300
300
  model: string;
@@ -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
- value: string | number | boolean | string[] | number[] | null;
311
310
  field: string;
311
+ value: string | number | boolean | string[] | number[] | null;
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
- value: string | number | boolean | string[] | number[] | null;
346
345
  field: string;
346
+ value: string | number | boolean | string[] | number[] | null;
347
347
  }[] | undefined;
348
348
  model: string;
349
349
  update: {
@@ -2089,7 +2089,11 @@ const migrationRunTable = convexTable(MIGRATION_RUN_TABLE, {
2089
2089
  completedAt: integer(),
2090
2090
  cancelRequested: boolean$1().notNull(),
2091
2091
  lastError: text()
2092
- }, (t) => [index("by_run_id").on(t.runId), index("by_status").on(t.status)]);
2092
+ }, (t) => [
2093
+ index("by_run_id").on(t.runId),
2094
+ index("by_status").on(t.status),
2095
+ index("by_started_at").on(t.startedAt)
2096
+ ]);
2093
2097
  const migrationStorageTables = {
2094
2098
  [MIGRATION_STATE_TABLE]: migrationStateTable,
2095
2099
  [MIGRATION_RUN_TABLE]: migrationRunTable
@@ -2805,7 +2809,7 @@ const GENERATED_ORM_RUNTIME_PROCEDURES = [
2805
2809
  {
2806
2810
  exportName: "migrationStatus",
2807
2811
  internal: true,
2808
- type: "mutation"
2812
+ type: "query"
2809
2813
  },
2810
2814
  {
2811
2815
  exportName: "migrationCancel",
@@ -2837,7 +2841,7 @@ const GENERATED_AGGREGATE_RUNTIME_PROCEDURES = [
2837
2841
  {
2838
2842
  exportName: "aggregateBackfillStatus",
2839
2843
  internal: true,
2840
- type: "mutation"
2844
+ type: "query"
2841
2845
  }
2842
2846
  ];
2843
2847
  function listFilesRecursive(cwd, relDir = "") {
@@ -3413,7 +3417,7 @@ import type {
3413
3417
  MutationCtx as ServerMutationCtx,
3414
3418
  QueryCtx as ServerQueryCtx,
3415
3419
  } from ${serverTypesImportLiteral};
3416
- import { httpAction, internalMutation } from ${serverTypesImportLiteral};
3420
+ import { httpAction, internalMutation, internalQuery } from ${serverTypesImportLiteral};
3417
3421
  import schema from ${schemaImportLiteral};
3418
3422
  import { procedureNames } from ${procedureNamesImportLiteral};
3419
3423
  ${migrationsImportLine}
@@ -3433,6 +3437,7 @@ export const orm = createOrm({
3433
3437
  schema: ormSchema,
3434
3438
  ormFunctions,
3435
3439
  ${capabilitiesConfigLine}${migrationsConfigLine} internalMutation,
3440
+ internalQuery,
3436
3441
  });
3437
3442
 
3438
3443
  export type OrmCtx<Ctx extends ServerQueryCtx | ServerMutationCtx = ServerQueryCtx> = GenericOrmCtx<Ctx, typeof ormSchema>;
@@ -3476,7 +3481,7 @@ function emitGeneratedAggregateFile(outputFile, functionsDir) {
3476
3481
  import { createOrm, type OrmFunctions } from 'kitcn/orm';
3477
3482
  import { aggregateCapability } from 'kitcn/orm/aggregate-index';
3478
3483
  import { createGeneratedFunctionReference } from 'kitcn/server';
3479
- import { internalMutation } from ${serverTypesImportLiteral};
3484
+ import { internalMutation, internalQuery } from ${serverTypesImportLiteral};
3480
3485
  import schema from ${schemaImportLiteral};
3481
3486
 
3482
3487
  const ormFunctions: OrmFunctions = {
@@ -3490,6 +3495,7 @@ const orm = createOrm({
3490
3495
  ormFunctions,
3491
3496
  capabilities: [aggregateCapability()],
3492
3497
  internalMutation,
3498
+ internalQuery,
3493
3499
  });
3494
3500
 
3495
3501
  export const {
@@ -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-BAiI8avr.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-6PZBmvc8.js";
2
2
 
3
3
  //#region src/orm/aggregate-index/capability.d.ts
4
4
  /**
@@ -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-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";
1
+ import { $n as TableName, $t as OrmLifecycleChange, An as ConvexCheckBuilder, At as UpdateSet, Bn as ConvexTextBuilder, Br as IsPrimaryKey, Bt as RelationsBuilderColumnBase, C as MigrationStep, Cn as ConvexVectorIndexConfig, Cr as not, Ct as OrderByClause, D as defineMigration, Dn as searchIndex, Dr as startsWith, Dt as ReturningAll, E as buildMigrationPlan, En as rankIndex, Er as or, Et as PredicateWhereIndexConfig, Fn as ConvexUniqueConstraintBuilderOn, Fr as ColumnBuilderTypeConfig, Ft as ExtractTablesFromSchema, Gn as Columns, Gt as TablesRelationalConfig, H as RlsMode, Hn as text, Hr as NotNull, In as ConvexUniqueConstraintConfig, Ir as ColumnBuilderWithTableName, It as ExtractTablesWithRelations, Jn as OrmSchemaExtensionTables, Jt as ConvexDeletionBuilder, Kt as defineRelations, Ln as check, Lr as ColumnDataType, Lt as ManyConfig, M as DatabaseWithQuery, Mn as ConvexForeignKeyBuilder, Mr as ColumnBuilder, Mt as VectorSearchProvider, N as OrmReader$1, Nn as ConvexForeignKeyConfig, Nr as ColumnBuilderBaseConfig, Nt as unsetToken, O as defineMigrationSet, On as uniqueIndex, Ot as ReturningResult, P as OrmWriter$1, Pn as ConvexUniqueConstraintBuilder, Pr as ColumnBuilderRuntimeConfig, Qn as OrmSchemaTriggers, Qt as DiscriminatorBuilderConfig, Rn as foreignKey, Rr as DrizzleEntity, Rt as OneConfig, S as MigrationStateMap, Sn as ConvexVectorIndexBuilderOn, Sr as ne, St as MutationRunMode, T as MigrationWriteMode, Tn as index, Tr as notInArray, Tt as PaginatedResult, U as EdgeMetadata, V as RlsContext, Vn as ConvexTextBuilderInitial, Vr as IsUnique, Vt as RelationsBuilderColumnConfig, W as extractRelationsConfig, Wn as Brand, Wt as TableRelationalConfig, Xn as OrmSchemaExtensions, Xt as ConvexTable, Yt as ConvexDeletionConfig, Zn as OrmSchemaRelations, Zt as ConvexTableWithColumns, _ as MigrationManifestEntry, _n as ConvexRankIndexBuilderOn, _r as isNotNull, _t as MutationExecutionMode, an as RlsPolicy, ar as UnaryExpression, at as BuildRelationResult, b as MigrationRunStatus, bn as ConvexSearchIndexConfig, br as lt, bt as MutationResult, cn as rlsPolicy, cr as contains, ct as DBQueryConfig, d as MigrationAppliedState, dn as rlsRole, dr as fieldRef, dt as InferInsertModel, en as OrmLifecycleOperation, er as BinaryExpression, f as MigrationDefinition, fn as ConvexAggregateIndexBuilder, fr as gt, ft as InferModelFromColumns, g as MigrationDriftIssue, gn as ConvexRankIndexBuilder, gr as isFieldReference, gt as MutationExecuteResult, h as MigrationDocContext, hn as ConvexIndexBuilderOn, hr as inArray, ht as MutationExecuteConfig, i as OrmMigrationCapability, in as discriminator, ir as LogicalExpression, it as BuildQueryResult, j as DatabaseWithMutations, jn as ConvexCheckConfig, jr as AnyColumn, jt as VectorQueryConfig, k as detectMigrationDrift, kn as vectorIndex, kr as SystemFields, kt as ReturningSelection, ln as RlsRole, lr as endsWith, lt as FilterOperators, m as MigrationDoc, mn as ConvexIndexBuilder, mr as ilike, mt as InsertValue, n as OrmCapabilities, nn as convexTable, nr as FieldReference, nt as AggregateFieldValue, on as RlsPolicyConfig, or as and, ot as CountConfig, p as MigrationDirection, pn as ConvexAggregateIndexBuilderOn, pr as gte, pt as InferSelectModel, qt as defineRelationsPart, r as OrmCapability, rn as deletion, rr as FilterExpression, rt as AggregateResult, sn as RlsPolicyToOption, sr as between, st as CountResult, t as OrmAggregateCapability, tn as TableConfig, tr as ExpressionVisitor, tt as AggregateConfig, un as RlsRoleConfig, ur as eq, ut as GetColumnData, v as MigrationMigrateOne, vn as ConvexSearchIndexBuilder, vr as isNull, vt as MutationPaginateConfig, w as MigrationTableName, wn as aggregateIndex, wr as notBetween, wt as OrderDirection, x as MigrationSet, xn as ConvexVectorIndexBuilder, xr as lte, xt as MutationReturning, y as MigrationPlan, yn as ConvexSearchIndexBuilderOn, yr as like, yt as MutationPaginatedResult, zn as unique, zr as HasDefault, zt as RelationsBuilder } from "../capabilities-6PZBmvc8.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-CX5-0M5p.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
@@ -1,5 +1,5 @@
1
1
  import { A as integer, C as index, D as vectorIndex, E as uniqueIndex, F as unionOf, I as ConvexColumnBuilder, L as entityKind, M as custom, N as json, O as text, P as objectOf, S as aggregateIndex, T as searchIndex, a as Columns, b as RlsPolicy, c as OrmSchemaDefinition, d as OrmSchemaExtensionTriggers, f as OrmSchemaExtensions, g as RlsPolicies, h as OrmSchemaTriggers, i as Brand, j as arrayOf, k as createSystemFields, l as OrmSchemaExtensionRelations, m as OrmSchemaRelations, n as deletion, o as EnableRLS, p as OrmSchemaOptions, r as discriminator, s as OrmContext, t as convexTable, u as OrmSchemaExtensionTables, v as TableName, w as rankIndex, x as rlsPolicy, y as TablePolymorphic } from "../table-CX2lnX7e.js";
2
- import { d as boolean, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, r as defineMigrationSet, t as buildMigrationPlan } from "../definitions-Dzk8mSTL.js";
2
+ import { d as boolean, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, r as defineMigrationSet, t as buildMigrationPlan } from "../definitions-DS8ZDc74.js";
3
3
  import { a as pretendRequired, i as pretend, n as deprecated } from "../validators-CIoUYCqO.js";
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";
@@ -7,7 +7,7 @@ import { a as indexKeyWithinBounds, c as streamIndexRange, i as getIndexFields,
7
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
- import { defineSchema as defineSchema$1, internalActionGeneric, internalMutationGeneric } from "convex/server";
10
+ import { defineSchema as defineSchema$1, internalActionGeneric, internalMutationGeneric, internalQueryGeneric } from "convex/server";
11
11
 
12
12
  //#region src/orm/builders/bigint.ts
13
13
  /**
@@ -7861,6 +7861,7 @@ function createOrm(config) {
7861
7861
  with: withContext
7862
7862
  };
7863
7863
  const mutationBuilder = config.internalMutation ?? internalMutationGeneric;
7864
+ const queryBuilder = config.internalQuery ?? internalQueryGeneric;
7864
7865
  return {
7865
7866
  db,
7866
7867
  with: withContext,
@@ -7926,7 +7927,7 @@ function createOrm(config) {
7926
7927
  handler: ((ctx, args) => countBackfillHandlers().kickoff(ctx, args))
7927
7928
  }),
7928
7929
  aggregateBackfillChunk,
7929
- aggregateBackfillStatus: mutationBuilder({
7930
+ aggregateBackfillStatus: queryBuilder({
7930
7931
  args: v.any(),
7931
7932
  handler: ((ctx, args) => countBackfillHandlers().status(ctx, args))
7932
7933
  }),
@@ -7935,7 +7936,7 @@ function createOrm(config) {
7935
7936
  handler: ((ctx, args) => migrationHandlers().run(ctx, args))
7936
7937
  }),
7937
7938
  migrationRunChunk,
7938
- migrationStatus: mutationBuilder({
7939
+ migrationStatus: queryBuilder({
7939
7940
  args: v.any(),
7940
7941
  handler: ((ctx, args) => migrationHandlers().status(ctx, args))
7941
7942
  }),
@@ -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-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
- 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 };
1
+ import { C as MigrationStep, D as defineMigration, E as buildMigrationPlan, O as defineMigrationSet, S as MigrationStateMap, T as MigrationWriteMode, _ as MigrationManifestEntry, a as MAX_STATUS_RUN_LIMIT, b as MigrationRunStatus, c as MigrationRunChunkArgs, d as MigrationAppliedState, f as MigrationDefinition, g as MigrationDriftIssue, h as MigrationDocContext, k as detectMigrationDrift, l as MigrationStatusArgs, m as MigrationDoc, o as MigrationCancelArgs, p as MigrationDirection, s as MigrationRunArgs, u as createMigrationHandlers, v as MigrationMigrateOne, w as MigrationTableName, x as MigrationSet, y as MigrationPlan } from "../../capabilities-6PZBmvc8.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-CX5-0M5p.js";
3
+ export { MAX_STATUS_RUN_LIMIT, MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
@@ -1,7 +1,15 @@
1
- import { a as MIGRATION_RUN_TABLE, c as injectMigrationStorageTables, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, o as MIGRATION_STATE_TABLE, r as defineMigrationSet, s as MIGRATION_STORAGE_TABLE_NAMES, t as buildMigrationPlan, u as migrationStorageTables } from "../../definitions-Dzk8mSTL.js";
1
+ import { a as MIGRATION_RUN_TABLE, c as injectMigrationStorageTables, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, o as MIGRATION_STATE_TABLE, r as defineMigrationSet, s as MIGRATION_STORAGE_TABLE_NAMES, t as buildMigrationPlan, u as migrationStorageTables } from "../../definitions-DS8ZDc74.js";
2
2
 
3
3
  //#region src/orm/migrations/runtime.ts
4
4
  const DEFAULT_BATCH_SIZE = 128;
5
+ const DEFAULT_STATUS_RUN_LIMIT = 25;
6
+ /**
7
+ * Hard ceiling on how many `migration_run` rows one `status()` call may read.
8
+ *
9
+ * `limit` is caller-supplied, so bounding the query without bounding the
10
+ * argument would just move the unbounded read behind the args surface.
11
+ */
12
+ const MAX_STATUS_RUN_LIMIT = 100;
5
13
  function createMigrationHandlers(params) {
6
14
  const { schema, migrations, getOrm, getChunkRef } = params;
7
15
  const knownTables = new Set(Object.values(schema).map((tableConfig) => tableConfig.name));
@@ -287,12 +295,11 @@ function createMigrationHandlers(params) {
287
295
  status: "noop",
288
296
  reason: "no_migrations_registered"
289
297
  };
290
- const limit = parseOptionalPositiveInteger(args.limit, "limit") ?? 25;
298
+ const limit = Math.min(parseOptionalPositiveInteger(args.limit, "limit") ?? DEFAULT_STATUS_RUN_LIMIT, MAX_STATUS_RUN_LIMIT);
291
299
  const runId = parseOptionalString(args.runId, "runId");
292
300
  const stateRows = await getAllStateRows(ctx.db);
293
- const sortedRuns = [...await getAllRunRows(ctx.db)].sort((left, right) => right.startedAt - left.startedAt);
294
- const selectedRuns = runId ? sortedRuns.filter((entry) => entry.runId === runId).slice(0, 1) : sortedRuns.slice(0, limit);
295
- const activeRun = sortedRuns.find((entry) => entry.status === "running") ?? null;
301
+ const selectedRuns = runId ? await getRunsById(ctx.db, runId) : await getRecentRuns(ctx.db, limit);
302
+ const activeRun = await getActiveRun(ctx.db);
296
303
  const appliedState = toAppliedStateMap(stateRows);
297
304
  const drift = detectMigrationDrift({
298
305
  migrationSet: migrations,
@@ -405,11 +412,21 @@ function toAppliedStateMap(stateRows) {
405
412
  };
406
413
  return entries;
407
414
  }
415
+ /**
416
+ * Bounded by the number of authored migrations, not by run history, and the
417
+ * full set is part of the `status()` payload (`migrations`, `pending`,
418
+ * `drift`), so this one stays a collect.
419
+ */
408
420
  async function getAllStateRows(db) {
409
421
  return await db.query(MIGRATION_STATE_TABLE).collect();
410
422
  }
411
- async function getAllRunRows(db) {
412
- return await db.query(MIGRATION_RUN_TABLE).collect();
423
+ /** Most recent `limit` runs, read straight off `by_started_at` in reverse. */
424
+ async function getRecentRuns(db, limit) {
425
+ return await db.query(MIGRATION_RUN_TABLE).withIndex("by_started_at").order("desc").take(limit);
426
+ }
427
+ async function getRunsById(db, runId) {
428
+ const row = await getRunById(db, runId);
429
+ return row ? [row] : [];
413
430
  }
414
431
  async function getRunById(db, runId) {
415
432
  return await db.query(MIGRATION_RUN_TABLE).withIndex("by_run_id", (query) => query.eq("runId", runId)).first() ?? null;
@@ -503,4 +520,4 @@ const migrationCapability = () => ({
503
520
  });
504
521
 
505
522
  //#endregion
506
- export { MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
523
+ export { MAX_STATUS_RUN_LIMIT, MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
package/dist/watcher.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as generateMeta, d as PARSE_SNAPSHOT_SUFFIX, i as resolveConfiguredBackend, n as withLocalCodegenEnv, o as getConvexConfig, r as loadCliConfig, u as logger } from "./local-env-Z8jj6ecD.mjs";
2
+ import { a as generateMeta, d as PARSE_SNAPSHOT_SUFFIX, i as resolveConfiguredBackend, n as withLocalCodegenEnv, o as getConvexConfig, r as loadCliConfig, u as logger } from "./local-env-Dk8RJvt5.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
@@ -1,7 +1,7 @@
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";
1
+ import { $t as OrmLifecycleChange, A as CreateDatabaseOptions, Ar as $Type, B as getUniqueIndexes, Ct as OrderByClause, F as CascadeMode, Ft as ExtractTablesFromSchema, Gn as Columns, Gt as TablesRelationalConfig, Ht as RelationsBuilderConfigValue, I as DeleteMode, Kn as OrmRuntimeDefaults, L as SerializedFilterExpression, Mr as ColumnBuilder, Mt as VectorSearchProvider, N as OrmReader, Nr as ColumnBuilderBaseConfig, Or as SystemFieldAliases, P as OrmWriter, Pt as AnyRelationsBuilderConfig, Qn as OrmSchemaTriggers, R as getChecks, U as EdgeMetadata, Un as ConvexColumnBuilder, Ur as entityKind, Ut as RelationsConfigWithSchema, Vn as ConvexTextBuilderInitial, Wt as TableRelationalConfig, Xt as ConvexTable, Yn as OrmSchemaExtensionTriggers, Zn as OrmSchemaRelations, Zt as ConvexTableWithColumns, an as RlsPolicy, dt as InferInsertModel, kr as SystemFields, pt as InferSelectModel, qn as OrmSchemaExtensionRelations, r as OrmCapability, rr as FilterExpression$1, x as MigrationSet, z as getForeignKeys, zr as HasDefault, zt as RelationsBuilder } from "./capabilities-6PZBmvc8.js";
2
2
  import * as convex_values0 from "convex/values";
3
3
  import { GenericId, Validator, Value } from "convex/values";
4
- import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchedulableFunctionReference, Scheduler, SchemaDefinition, internalActionGeneric, internalMutationGeneric } from "convex/server";
4
+ import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchedulableFunctionReference, Scheduler, SchemaDefinition, internalActionGeneric, internalMutationGeneric, internalQueryGeneric } from "convex/server";
5
5
 
6
6
  //#region src/orm/migrations/capability.d.ts
7
7
  /**
@@ -396,6 +396,7 @@ declare const migrationStorageTables: {
396
396
  by_creation_time: ["_creationTime"];
397
397
  by_status: ["status", "_creationTime"];
398
398
  by_run_id: ["runId", "_creationTime"];
399
+ by_started_at: ["startedAt", "_creationTime"];
399
400
  }, {}, {}, {}>;
400
401
  };
401
402
  declare const MIGRATION_STORAGE_TABLE_NAMES: Set<string>;
@@ -491,6 +492,7 @@ type CreateOrmConfigBase<TSchema extends OrmSchemaInput> = {
491
492
  capabilities?: readonly OrmCapability[];
492
493
  migrations?: MigrationSet<any>;
493
494
  internalMutation?: typeof internalMutationGeneric;
495
+ internalQuery?: typeof internalQueryGeneric;
494
496
  };
495
497
  type CreateOrmConfigWithFunctions<TSchema extends OrmSchemaInput> = CreateOrmConfigBase<TSchema> & {
496
498
  ormFunctions: OrmFunctions;
@@ -504,10 +506,10 @@ type OrmApiResult = {
504
506
  scheduledDelete: ReturnType<typeof internalMutationGeneric>;
505
507
  aggregateBackfill: ReturnType<typeof internalMutationGeneric>;
506
508
  aggregateBackfillChunk: ReturnType<typeof internalMutationGeneric>;
507
- aggregateBackfillStatus: ReturnType<typeof internalMutationGeneric>;
509
+ aggregateBackfillStatus: ReturnType<typeof internalQueryGeneric>;
508
510
  migrationRun: ReturnType<typeof internalMutationGeneric>;
509
511
  migrationRunChunk: ReturnType<typeof internalMutationGeneric>;
510
- migrationStatus: ReturnType<typeof internalMutationGeneric>;
512
+ migrationStatus: ReturnType<typeof internalQueryGeneric>;
511
513
  migrationCancel: ReturnType<typeof internalMutationGeneric>;
512
514
  resetChunk: ReturnType<typeof internalMutationGeneric>;
513
515
  reset: ReturnType<typeof internalActionGeneric>;
@@ -2038,6 +2040,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
2038
2040
  by_creation_time: ["_creationTime"];
2039
2041
  by_status: ["status", "_creationTime"];
2040
2042
  by_run_id: ["runId", "_creationTime"];
2043
+ by_started_at: ["startedAt", "_creationTime"];
2041
2044
  }, {}, {}, {}>;
2042
2045
  }>];
2043
2046
  declare function defineSchema$1<TSchema extends GenericSchema, StrictTableNameTypes extends boolean = true>(schema: TSchema, options?: SchemaOptions<StrictTableNameTypes>): SchemaChain<TSchema, StrictTableNameTypes, readonly [], undefined, true, true, true>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -56,7 +56,7 @@ const orders = convexTable(
56
56
  - `.all()` — unfiltered global metrics
57
57
  - `.count(field)` / `.sum(field)` / `.avg(field)` / `.min(field)` / `.max(field)` — chainable metrics
58
58
 
59
- After deploying, CLI runs `aggregateBackfill` automatically. Wait for `aggregateBackfillStatus` to report `READY`.
59
+ After deploying, CLI runs `aggregateBackfill` automatically. Wait for `aggregateBackfillStatus` (an internal query) to report `READY`.
60
60
 
61
61
  ### `count()` — O(1) No-Scan Counts
62
62
 
@@ -137,6 +137,23 @@ Applied migrations are immutable. Two drift checks:
137
137
 
138
138
  Reserved names — do not create tables with these names.
139
139
 
140
+ ## Status Procedure
141
+
142
+ `generated/server:migrationStatus` is an internal **query** — reading status
143
+ takes no write transaction and can back a live subscription.
144
+
145
+ | Arg | Description |
146
+ |-----|-------------|
147
+ | `limit` | Most recent runs to list. Default `25`, capped at `MAX_STATUS_RUN_LIMIT` (`100`); higher values clamp. |
148
+ | `runId` | Return only this run. Ignores `limit`. |
149
+
150
+ `activeRun` resolves independently of `runId`. `migrations`, `pending`, and
151
+ `drift` always cover every authored migration and ignore `limit`.
152
+
153
+ ```ts
154
+ import { MAX_STATUS_RUN_LIMIT } from 'kitcn/orm/migrations';
155
+ ```
156
+
140
157
  ## Runtime Statuses
141
158
 
142
159
  `pending` → `running` → `completed` | `failed` | `canceled` | `dry_run` | `noop` | `drift_blocked`