kitcn 0.30.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/aggregate/index.d.ts +11 -6
  3. package/dist/aggregate/index.js +2 -1
  4. package/dist/auth/generated/index.d.ts +1 -1
  5. package/dist/auth/generated/index.js +1 -1
  6. package/dist/auth/http/index.d.ts +1 -1
  7. package/dist/auth/index.d.ts +15 -15
  8. package/dist/auth/index.js +133 -9
  9. package/dist/auth/nextjs/index.d.ts +2 -2
  10. package/dist/auth/nextjs/index.js +3 -3
  11. package/dist/auth/start/server/index.d.ts +2 -2
  12. package/dist/auth/start/server/index.js +3 -3
  13. package/dist/{builder-CsAw-DK8.js → builder-Cyd5nCxZ.js} +2 -2
  14. package/dist/{caller-factory-D4pz5GcZ.js → caller-factory-C-N540BC.js} +3 -3
  15. package/dist/{capabilities-6PZBmvc8.d.ts → capabilities-CG-oIMyR.d.ts} +25 -11
  16. package/dist/cli.mjs +1 -1
  17. package/dist/{create-schema-orm-HcJzGCxj.js → create-schema-orm-CwJD930B.js} +1 -1
  18. package/dist/crpc/index.d.ts +2 -2
  19. package/dist/crpc/index.js +3 -3
  20. package/dist/{customFunctions-ivbc6-_g.js → customFunctions-X_B4kET8.js} +64 -1
  21. package/dist/{definitions-DS8ZDc74.js → definitions-3PX4ywR-.js} +2 -2
  22. package/dist/{extensions-Blzsyekm.js → extensions-Bp0XHanR.js} +1 -1
  23. package/dist/{generated-contract-disabled-CgYQZCw2.d.ts → generated-contract-disabled-BKvk4lFx.d.ts} +41 -12
  24. package/dist/{generated-contract-disabled-_1Mjg9pW.js → generated-contract-disabled-RyPYlwq0.js} +1 -0
  25. package/dist/{http-types-90mapMP9.d.ts → http-types-BhhPZtwa.d.ts} +2 -2
  26. package/dist/{filter-expression-Dydt8wS0.js → index-utils-C1DyktHe.js} +95 -1
  27. package/dist/{local-env-Dk8RJvt5.mjs → local-env-CYYSNf_o.mjs} +92 -72
  28. package/dist/{middleware-CE_MC6Gi.d.ts → middleware-BBS7oLtT.d.ts} +1 -1
  29. package/dist/{middleware-BvnabcNq.js → middleware-D61Nm-iB.js} +1 -1
  30. package/dist/orm/aggregate-index/index.d.ts +1 -1
  31. package/dist/orm/aggregate-index/index.js +32 -34
  32. package/dist/orm/index.d.ts +4 -4
  33. package/dist/orm/index.js +8 -7
  34. package/dist/orm/migrations/index.d.ts +2 -2
  35. package/dist/orm/migrations/index.js +1 -1
  36. package/dist/plugins/index.d.ts +1 -1
  37. package/dist/plugins/index.js +1 -1
  38. package/dist/{procedure-caller-BR-Wb0si.js → procedure-caller-DgMiD0-a.js} +2 -2
  39. package/dist/{procedure-name-l2YusEZI.d.ts → procedure-name-DPYyLiVS.d.ts} +3 -3
  40. package/dist/ratelimit/index.d.ts +2 -2
  41. package/dist/ratelimit/index.js +3 -3
  42. package/dist/rsc/index.d.ts +4 -4
  43. package/dist/rsc/index.js +4 -4
  44. package/dist/{runtime-CcOvOf4K.js → runtime-B-8HKSIE.js} +21 -40
  45. package/dist/schema-BFP_awgP.js +67 -0
  46. package/dist/{schema-D8ZZMSKd.js → schema-DbPcDW-N.js} +10 -117
  47. package/dist/server/index.d.ts +4 -4
  48. package/dist/server/index.js +4 -4
  49. package/dist/symbols-DDNAddkd.js +21 -0
  50. package/dist/{table-CX2lnX7e.js → table-d9o_n4R3.js} +2 -21
  51. package/dist/{token-B0NKKxqP.js → token-CuJopBdP.js} +1 -1
  52. package/dist/{types-In-ZZOsd.d.ts → types-BXpu7xIU.d.ts} +1 -1
  53. package/dist/watcher.mjs +1 -1
  54. package/dist/{where-clause-compiler-DvYSTJXe.d.ts → where-clause-compiler-Bgkzm3Y-.d.ts} +85 -81
  55. package/package.json +1 -1
  56. package/dist/id-CuSfWa5q.js +0 -37
  57. /package/dist/{api-entry-CkDpGYVg.js → api-entry-Buvjl9hn.js} +0 -0
  58. /package/dist/{context-utils-DwZ3Cam1.d.ts → context-utils-Cbv4r0AA.d.ts} +0 -0
  59. /package/dist/{convex-plugin-Dic0l-k8.js → convex-plugin-AbNQl1Sg.js} +0 -0
  60. /package/dist/{create-schema-ojI-OH_9.js → create-schema-BmVH4gPc.js} +0 -0
  61. /package/dist/{error-CMLeCadS.js → error-Dyqhgbf6.js} +0 -0
  62. /package/dist/{meta-utils-D2lqN2Lg.js → meta-utils-Cc7neQOB.js} +0 -0
  63. /package/dist/{query-context-DJONf8X5.d.ts → query-context-BkNjkDCk.d.ts} +0 -0
  64. /package/dist/{query-context-DOm5Xm3H.js → query-context-DdSg3fuk.js} +0 -0
  65. /package/dist/{query-options-DUiOj01a.js → query-options-DGG93--5.js} +0 -0
  66. /package/dist/{token-kQaqFby4.d.ts → token-tlbNKQS0.d.ts} +0 -0
  67. /package/dist/{transformer-D8wO-kEj.js → transformer-C8lVwHNT.js} +0 -0
  68. /package/dist/{types-eNzQmbqM.d.ts → types-Bkeicpo6.d.ts} +0 -0
  69. /package/dist/{types-MHYXboyy.d.ts → types-Bqi_ivSd.d.ts} +0 -0
  70. /package/dist/{types-Bf3XQex5.d.ts → types-ex0-J-SC.d.ts} +0 -0
  71. /package/dist/{validators-wOIjhkfN.d.ts → validators-0I-Ik1EN.d.ts} +0 -0
@@ -1,6 +1,7 @@
1
- import { t as DirectAggregate } from "../../runtime-CcOvOf4K.js";
2
- import { a as Columns } from "../../table-CX2lnX7e.js";
3
- import { Dt as PUBLIC_CREATED_AT_FIELD, Et as INTERNAL_CREATION_TIME_FIELD, Ot as usesSystemCreatedAtAlias, Q as normalizeTemporalComparableValue, a as AGGREGATE_STATE_TABLE, c as getAggregateIndexDefinitions, d as COUNT_ERROR, ht as mapWithConcurrency, i as AGGREGATE_RANK_TREE_TABLE, l as getRankIndexDefinitions, m as createError, n as AGGREGATE_EXTREMA_TABLE, r as AGGREGATE_MEMBER_TABLE, s as rankAggregateName, t as AGGREGATE_BUCKET_TABLE, u as AGGREGATE_ERROR } from "../../schema-D8ZZMSKd.js";
1
+ import { t as DirectAggregate } from "../../runtime-B-8HKSIE.js";
2
+ import { n as Columns } from "../../symbols-DDNAddkd.js";
3
+ import { d as INTERNAL_CREATION_TIME_FIELD, f as PUBLIC_CREATED_AT_FIELD, m as usesSystemCreatedAtAlias } from "../../index-utils-C1DyktHe.js";
4
+ import { Q as normalizeTemporalComparableValue, a as AGGREGATE_STATE_TABLE, c as getAggregateIndexDefinitions, d as COUNT_ERROR, ht as mapWithConcurrency, i as AGGREGATE_RANK_TREE_TABLE, l as getRankIndexDefinitions, m as createError, n as AGGREGATE_EXTREMA_TABLE, r as AGGREGATE_MEMBER_TABLE, s as rankAggregateName, t as AGGREGATE_BUCKET_TABLE, u as AGGREGATE_ERROR } from "../../schema-DbPcDW-N.js";
4
5
 
5
6
  //#region src/orm/transaction-cache.ts
6
7
  /**
@@ -1410,23 +1411,21 @@ const setCountStateError = async (db, tableName, indexName, error, kind = AGGREG
1410
1411
  * reports whether anything is left. Callers drive it to completion across
1411
1412
  * transactions, so clearing a large index never has to fit in one mutation.
1412
1413
  *
1413
- * Members are removed through the normal delta machinery rather than raw
1414
- * deletes, so buckets and extrema stay consistent with the members that remain
1415
- * at every intermediate step. That keeps concurrent writers correct while the
1416
- * clear drains. Residual bucket/extrema rows (drift with no member behind them)
1417
- * are swept only once no members are left, and the loop re-checks members
1418
- * afterwards.
1414
+ * Member rows are deleted outright rather than run back through the delta
1415
+ * machinery. The bucket and extrema branches below drop every row this index
1416
+ * owns whatever it holds, so folding a removal delta into a bucket first would
1417
+ * only rewrite a document this same clear is about to delete.
1418
+ *
1419
+ * Branch order is load-bearing: buckets and extrema are swept only once no
1420
+ * members are left, and the loop re-checks members afterwards. The intermediate
1421
+ * "members gone, buckets still populated" state is safe because `setCountState`
1422
+ * refuses to leave CLEARING while a bucket or extrema row survives, and the
1423
+ * CLEARING write barrier keeps concurrent writers out of the index.
1419
1424
  */
1420
1425
  const clearCountIndexChunk = async (db, tableName, indexName, batchSize) => {
1421
1426
  const members = await takeMembersForIndex(db, tableName, indexName, batchSize);
1422
1427
  if (members.length > 0) {
1423
- await flushAggregateMembershipDeltas(db, tableName, indexName, members.map((member) => computeMembershipDelta(member, {
1424
- tableName,
1425
- indexName,
1426
- docId: member.docId,
1427
- keyParts: null,
1428
- metricValues: null
1429
- })));
1428
+ for (const member of members) await db.delete(AGGREGATE_MEMBER_TABLE, member._id);
1430
1429
  return {
1431
1430
  done: false,
1432
1431
  processed: members.length
@@ -1592,36 +1591,35 @@ const rankCtx = (db) => ({
1592
1591
  db,
1593
1592
  orm: void 0
1594
1593
  });
1595
- /** Trees dropped per invocation once every rank member has been removed. */
1596
- const RANK_TREE_DROP_BATCH = 16;
1597
1594
  /**
1598
- * Removes at most `batchSize` rank members and reports whether anything is
1599
- * left. Each member is removed from the btree before its row is dropped, so the
1600
- * tree stays consistent with the members that remain and a partially drained
1601
- * clear can safely resume in a later mutation.
1595
+ * Removes at most `batchSize` documents of a rank index's stored state and
1596
+ * reports whether anything is left. Callers drive it to completion across
1597
+ * transactions, so clearing a large index never has to fit in one mutation.
1598
+ *
1599
+ * Member rows are dropped without touching the btree. The tree branch below
1600
+ * deletes every node whatever it contains, so removing a member key first would
1601
+ * only buy a root-to-leaf descent plus an aggregate patch per level on nodes
1602
+ * this same clear is about to delete.
1603
+ *
1604
+ * Branch order is load-bearing: a member delete recreates the tree it lands on,
1605
+ * so the members must be gone before the first node is dropped. The
1606
+ * intermediate "members gone, tree still full" state is safe because
1607
+ * `setCountState` refuses to leave CLEARING while a tree row survives, and the
1608
+ * CLEARING write barrier keeps concurrent writers out of the index.
1602
1609
  */
1603
1610
  const clearRankIndexChunk = async (db, tableName, indexName, batchSize) => {
1604
- const aggregate = rankAggregate(tableName, indexName);
1605
- const ctx = rankCtx(db);
1606
1611
  const members = await takeRankMembers(db, tableName, indexName, batchSize);
1607
1612
  if (members.length > 0) {
1608
- for (const member of members) {
1609
- if (member.rankKey !== void 0) await aggregate.deleteIfExists(ctx, {
1610
- id: member.docId,
1611
- key: member.rankKey,
1612
- namespace: member.rankNamespace
1613
- });
1614
- await db.delete(AGGREGATE_MEMBER_TABLE, member._id);
1615
- }
1613
+ for (const member of members) await db.delete(AGGREGATE_MEMBER_TABLE, member._id);
1616
1614
  return {
1617
1615
  done: false,
1618
1616
  processed: members.length
1619
1617
  };
1620
1618
  }
1621
- const done = await aggregate.deleteTrees(ctx, RANK_TREE_DROP_BATCH);
1619
+ const { documents, done } = await rankAggregate(tableName, indexName).deleteTrees(rankCtx(db), batchSize);
1622
1620
  return {
1623
1621
  done,
1624
- processed: done ? 0 : RANK_TREE_DROP_BATCH
1622
+ processed: documents
1625
1623
  };
1626
1624
  };
1627
1625
  const reconcileRankMembership = async (db, params) => {
@@ -1,7 +1,7 @@
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-DvYSTJXe.js";
3
- import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-wOIjhkfN.js";
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";
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-CG-oIMyR.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-Bgkzm3Y-.js";
3
+ import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-0I-Ik1EN.js";
4
+ import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-BkNjkDCk.js";
5
5
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
6
6
 
7
7
  //#region src/orm/index.d.ts
package/dist/orm/index.js CHANGED
@@ -1,11 +1,12 @@
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-DS8ZDc74.js";
1
+ import { _ as json, a as rlsPolicy, b as ConvexColumnBuilder, c as rankIndex, d as vectorIndex, f as text, g as custom, h as arrayOf, i as RlsPolicy, l as searchIndex, m as integer, n as deletion, o as aggregateIndex, p as createSystemFields, r as discriminator, s as index, t as convexTable, u as uniqueIndex, v as objectOf, x as entityKind, y as unionOf } from "../table-d9o_n4R3.js";
2
+ import { d as boolean, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, r as defineMigrationSet, t as buildMigrationPlan } from "../definitions-3PX4ywR-.js";
3
3
  import { a as pretendRequired, i as pretend, n as deprecated } from "../validators-CIoUYCqO.js";
4
- import { t as id } from "../id-CuSfWa5q.js";
5
- import { A as or, C as matchLikePattern, D as notIlike, E as notBetween, O as notInArray, S as lte, T as not, _ as isFieldReference, a as between, b as like, c as endsWith, d as filterValueInList, f as filterValuesEqual, g as inArray, h as ilike, i as arrayOverlaps, j as startsWith, k as notLike, l as eq, m as gte, n as arrayContained, o as column, p as gt, r as arrayContains, s as contains, t as and, u as fieldRef, v as isNotNull, w as ne, x as lt, y as isNull } from "../filter-expression-Dydt8wS0.js";
6
- import { a as indexKeyWithinBounds, c as streamIndexRange, i as getIndexFields, l as isUnsetToken, n as EmptyStream, o as mergedStream, r as QueryStream, s as stream, t as getByIdWithOrmQueryFallback, u as unsetToken } from "../query-context-DOm5Xm3H.js";
7
- import { $ as patchReferencingRows, A as enforcePolymorphicWrite, B as getForeignKeys, C as collectPrimaryIdLookupRows, Ct as getRankIndexes, D as encodeUndefinedDeep, Dt as PUBLIC_CREATED_AT_FIELD, E as deserializeFilterExpression, Et as INTERNAL_CREATION_TIME_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, Ot as usesSystemCreatedAtAlias, P as ensureNullableColumns, Q as normalizeTemporalComparableValue, R as getChecks, S as collectMutationRowsBounded, St as getIndexes, T as decodeUndefinedDeep, Tt as CREATED_AT_MIGRATION_MESSAGE, U as getMutationExecutionMode, V as getMutationAsyncDelayMs, W as getOrmContext, X as hydrateDateFieldsForRead, Y as hardDeleteRow, Z as normalizeDateFieldsForWrite, _ as applyDefaults, _t as findIndexForColumns, at as splitReturningSelection, b as buildForeignKeyGraph, bt as findVectorIndexByName, 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 findExactIndexForColumns, 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 findRelationIndex, w as createForeignKeyProbeMemo, wt as resolveIndexOrderPushdown, x as canUsePrimaryIdLookupCursor, xt as getAggregateIndexes, y as applyIncomingForeignKeyActionsOnUpdate, yt as findSearchIndexByName, z as getColumnName$1 } from "../schema-D8ZZMSKd.js";
8
- import { t as defineSchemaExtension } from "../extensions-Blzsyekm.js";
4
+ import { o as id } from "../schema-BFP_awgP.js";
5
+ import { a as OrmSchemaDefinition, c as OrmSchemaExtensionTriggers, d as OrmSchemaRelations, f as OrmSchemaTriggers, g as TablePolymorphic, h as TableName, i as OrmContext, l as OrmSchemaExtensions, n as Columns, o as OrmSchemaExtensionRelations, p as RlsPolicies, r as EnableRLS, s as OrmSchemaExtensionTables, t as Brand, u as OrmSchemaOptions } from "../symbols-DDNAddkd.js";
6
+ import { A as inArray, B as notBetween, C as eq, D as gt, E as filterValuesEqual, F as lt, G as startsWith, H as notInArray, I as lte, L as matchLikePattern, M as isNotNull, N as isNull, O as gte, P as like, R as ne, S as endsWith, T as filterValueInList, U as notLike, V as notIlike, W as or, _ as arrayContains, a as findVectorIndexByName, b as column, c as getRankIndexes, d as INTERNAL_CREATION_TIME_FIELD, f as PUBLIC_CREATED_AT_FIELD, g as arrayContained, h as and, i as findSearchIndexByName, j as isFieldReference, k as ilike, l as resolveIndexOrderPushdown, m as usesSystemCreatedAtAlias, n as findIndexForColumns, o as getAggregateIndexes, r as findRelationIndex, s as getIndexes, t as findExactIndexForColumns, u as CREATED_AT_MIGRATION_MESSAGE, v as arrayOverlaps, w as fieldRef, x as contains, y as between, z as not } from "../index-utils-C1DyktHe.js";
7
+ import { a as indexKeyWithinBounds, c as streamIndexRange, i as getIndexFields, l as isUnsetToken, n as EmptyStream, o as mergedStream, r as QueryStream, s as stream, t as getByIdWithOrmQueryFallback, u as unsetToken } from "../query-context-DdSg3fuk.js";
8
+ import { $ as patchReferencingRows, A as enforcePolymorphicWrite, B as getForeignKeys, C as collectPrimaryIdLookupRows, D as encodeUndefinedDeep, E as deserializeFilterExpression, 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, T as decodeUndefinedDeep, U as getMutationExecutionMode, V as getMutationAsyncDelayMs, W as getOrmContext, X as hydrateDateFieldsForRead, Y as hardDeleteRow, Z as normalizeDateFieldsForWrite, _ as applyDefaults, at as splitReturningSelection, b as buildForeignKeyGraph, 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, 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, w as createForeignKeyProbeMemo, x as canUsePrimaryIdLookupCursor, y as applyIncomingForeignKeyActionsOnUpdate, z as getColumnName$1 } from "../schema-DbPcDW-N.js";
9
+ import { t as defineSchemaExtension } from "../extensions-Bp0XHanR.js";
9
10
  import { compareValues, convexToJson, jsonToConvex, v } from "convex/values";
10
11
  import { defineSchema as defineSchema$1, internalActionGeneric, internalMutationGeneric, internalQueryGeneric } from "convex/server";
11
12
 
@@ -1,3 +1,3 @@
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-DvYSTJXe.js";
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-CG-oIMyR.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-Bgkzm3Y-.js";
3
3
  export { MAX_STATUS_RUN_LIMIT, MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
@@ -1,4 +1,4 @@
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";
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-3PX4ywR-.js";
2
2
 
3
3
  //#region src/orm/migrations/runtime.ts
4
4
  const DEFAULT_BATCH_SIZE = 128;
@@ -1,2 +1,2 @@
1
- import { a as PluginConfigureResolver, i as PluginConfigureInput, n as PluginApiScope, o as definePlugin, r as PluginConfigureContext, s as resolvePluginOptions, t as Plugin } from "../middleware-CE_MC6Gi.js";
1
+ import { a as PluginConfigureResolver, i as PluginConfigureInput, n as PluginApiScope, o as definePlugin, r as PluginConfigureContext, s as resolvePluginOptions, t as Plugin } from "../middleware-BBS7oLtT.js";
2
2
  export { type Plugin, type PluginApiScope, type PluginConfigureContext, type PluginConfigureInput, type PluginConfigureResolver, definePlugin, resolvePluginOptions };
@@ -1,3 +1,3 @@
1
- import { n as resolvePluginOptions, t as definePlugin } from "../middleware-BvnabcNq.js";
1
+ import { n as resolvePluginOptions, t as definePlugin } from "../middleware-D61Nm-iB.js";
2
2
 
3
3
  export { definePlugin, resolvePluginOptions };
@@ -1,5 +1,5 @@
1
- import { i as decodeWire, o as encodeWire } from "./transformer-D8wO-kEj.js";
2
- import { _ as CRPCError } from "./builder-CsAw-DK8.js";
1
+ import { i as decodeWire, o as encodeWire } from "./transformer-C8lVwHNT.js";
2
+ import { _ as CRPCError } from "./builder-Cyd5nCxZ.js";
3
3
  import * as z$1 from "zod";
4
4
 
5
5
  //#region src/server/env.ts
@@ -1,6 +1,6 @@
1
- import { t as VRequired } from "./validators-wOIjhkfN.js";
2
- import { A as HttpProcedureBuilderDef, D as HttpHandlerOpts, L as DataTransformerOptions, N as ProcedureMeta, O as HttpMethod, W as getTransformer, _ as CRPCHttpRouter, f as InferHttpInput, k as HttpProcedure, p as InferHttpOutput, y as HttpRouterRecord } from "./http-types-90mapMP9.js";
3
- import { g as UnsetMarker, i as IntersectIfDefined, o as MiddlewareBuilder, p as Overwrite$1, s as MiddlewareFunction, t as AnyMiddleware } from "./types-eNzQmbqM.js";
1
+ import { t as VRequired } from "./validators-0I-Ik1EN.js";
2
+ import { A as HttpProcedureBuilderDef, D as HttpHandlerOpts, L as DataTransformerOptions, N as ProcedureMeta, O as HttpMethod, W as getTransformer, _ as CRPCHttpRouter, f as InferHttpInput, k as HttpProcedure, p as InferHttpOutput, y as HttpRouterRecord } from "./http-types-BhhPZtwa.js";
3
+ import { g as UnsetMarker, i as IntersectIfDefined, o as MiddlewareBuilder, p as Overwrite$1, s as MiddlewareFunction, t as AnyMiddleware } from "./types-Bkeicpo6.js";
4
4
  import { ConvexError, GenericId, GenericValidator, ObjectType, OptionalProperty, PropertyValidators, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion, Validator, Value as Value$1 } from "convex/values";
5
5
  import { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionReference, FunctionReturnType, FunctionVisibility, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, MutationBuilder, QueryBuilder, RegisteredAction, RegisteredMutation, RegisteredQuery, TableNamesInDataModel } from "convex/server";
6
6
  import * as z$1 from "zod";
@@ -1,5 +1,5 @@
1
- import { o as MiddlewareBuilder } from "../types-eNzQmbqM.js";
2
- import { t as Plugin } from "../middleware-CE_MC6Gi.js";
1
+ import { o as MiddlewareBuilder } from "../types-Bkeicpo6.js";
2
+ import { t as Plugin } from "../middleware-BBS7oLtT.js";
3
3
  import * as convex_server0 from "convex/server";
4
4
 
5
5
  //#region src/ratelimit/duration.d.ts
@@ -1,6 +1,6 @@
1
- import { u as requireMutationCtx } from "../api-entry-CkDpGYVg.js";
2
- import { _ as CRPCError } from "../builder-CsAw-DK8.js";
3
- import { t as definePlugin } from "../middleware-BvnabcNq.js";
1
+ import { u as requireMutationCtx } from "../api-entry-Buvjl9hn.js";
2
+ import { _ as CRPCError } from "../builder-Cyd5nCxZ.js";
3
+ import { t as definePlugin } from "../middleware-D61Nm-iB.js";
4
4
  import { v } from "convex/values";
5
5
  import { mutationGeneric, queryGeneric } from "convex/server";
6
6
 
@@ -1,7 +1,7 @@
1
- import { n as DeepPartial, o as Simplify, r as DistributiveOmit } from "../types-MHYXboyy.js";
2
- import { L as DataTransformerOptions, _ as CRPCHttpRouter, c as HttpQueryKey, k as HttpProcedure, o as HttpMutationKey, y as HttpRouterRecord } from "../http-types-90mapMP9.js";
3
- import { g as UnsetMarker } from "../types-eNzQmbqM.js";
4
- import { A as HttpInputArgs, C as ReservedMutationOptions$1, S as ReservedInfiniteQueryOptions, T as StaticQueryOptsParam, _ as IsPaginated, b as PaginatedFnMeta, c as ConvexMutationKey, d as ConvexQueryMeta, f as EmptyObject, g as InfiniteQueryInput, l as ConvexQueryHookOptions, m as FUNC_REF_SYMBOL, o as ConvexActionKey, p as ExtractPaginatedItem, s as ConvexInfiniteQueryMeta, u as ConvexQueryKey, w as ReservedQueryOptions$1, y as MutationVariables } from "../types-In-ZZOsd.js";
1
+ import { n as DeepPartial, o as Simplify, r as DistributiveOmit } from "../types-Bqi_ivSd.js";
2
+ import { L as DataTransformerOptions, _ as CRPCHttpRouter, c as HttpQueryKey, k as HttpProcedure, o as HttpMutationKey, y as HttpRouterRecord } from "../http-types-BhhPZtwa.js";
3
+ import { g as UnsetMarker } from "../types-Bkeicpo6.js";
4
+ import { A as HttpInputArgs, C as ReservedMutationOptions$1, S as ReservedInfiniteQueryOptions, T as StaticQueryOptsParam, _ as IsPaginated, b as PaginatedFnMeta, c as ConvexMutationKey, d as ConvexQueryMeta, f as EmptyObject, g as InfiniteQueryInput, l as ConvexQueryHookOptions, m as FUNC_REF_SYMBOL, o as ConvexActionKey, p as ExtractPaginatedItem, s as ConvexInfiniteQueryMeta, u as ConvexQueryKey, w as ReservedQueryOptions$1, y as MutationVariables } from "../types-BXpu7xIU.js";
5
5
  import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
6
6
  import { z } from "zod";
7
7
  import { DefaultError, QueryFilters, SkipToken, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
package/dist/rsc/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { n as defaultIsUnauthorized } from "../error-CMLeCadS.js";
2
- import { n as getFuncRef, r as getFunctionMeta, t as buildMetaIndex } from "../meta-utils-D2lqN2Lg.js";
3
- import { o as encodeWire, s as getTransformer } from "../transformer-D8wO-kEj.js";
4
- import { c as HTTP_DEFAULT_STALE_TIME, n as convexInfiniteQueryOptions, o as executeHttpRequest, r as convexQuery, u as buildHttpQueryKey } from "../query-options-DUiOj01a.js";
1
+ import { n as defaultIsUnauthorized } from "../error-Dyqhgbf6.js";
2
+ import { n as getFuncRef, r as getFunctionMeta, t as buildMetaIndex } from "../meta-utils-Cc7neQOB.js";
3
+ import { o as encodeWire, s as getTransformer } from "../transformer-C8lVwHNT.js";
4
+ import { c as HTTP_DEFAULT_STALE_TIME, n as convexInfiniteQueryOptions, o as executeHttpRequest, r as convexQuery, u as buildHttpQueryKey } from "../query-options-DGG93--5.js";
5
5
  import { convexToJson } from "convex/values";
6
6
  import { getFunctionName } from "convex/server";
7
7
  import { fetchAction, fetchQuery } from "convex/nextjs";
@@ -1,6 +1,5 @@
1
- import { A as integer, C as index, M as custom, O as text, t as convexTable } from "./table-CX2lnX7e.js";
2
- import { t as id } from "./id-CuSfWa5q.js";
3
- import { ConvexError, convexToJson, jsonToConvex, v } from "convex/values";
1
+ import { n as AGGREGATE_TREE_TABLE, t as AGGREGATE_NODE_TABLE } from "./schema-BFP_awgP.js";
2
+ import { ConvexError, convexToJson, jsonToConvex } from "convex/values";
4
3
 
5
4
  //#region src/aggregate-core/compare.ts
6
5
  function isCommitTsPlaceholder(value) {
@@ -44,36 +43,6 @@ function makeComparable(v) {
44
43
  return [8, keys.map((k) => [k, record[k]]).map(makeComparable)];
45
44
  }
46
45
 
47
- //#endregion
48
- //#region src/aggregate-core/schema.ts
49
- const AGGREGATE_TREE_TABLE = "aggregate_rank_tree";
50
- const AGGREGATE_NODE_TABLE = "aggregate_rank_node";
51
- const aggregateCounterValidator = v.object({
52
- count: v.number(),
53
- sum: v.number()
54
- });
55
- const aggregateItemValidator = v.object({
56
- k: v.any(),
57
- v: v.any(),
58
- s: v.number()
59
- });
60
- const aggregateTreeTable = convexTable(AGGREGATE_TREE_TABLE, {
61
- aggregateName: text().notNull(),
62
- deletionStack: custom(v.array(v.id(AGGREGATE_NODE_TABLE))),
63
- maxNodeSize: integer().notNull(),
64
- namespace: custom(v.any()),
65
- root: id(AGGREGATE_NODE_TABLE).notNull()
66
- }, (tree) => [index("by_namespace").on(tree.namespace), index("by_aggregate_name").on(tree.aggregateName)]);
67
- const aggregateNodeTable = convexTable(AGGREGATE_NODE_TABLE, {
68
- aggregate: custom(aggregateCounterValidator),
69
- items: custom(v.array(aggregateItemValidator)).notNull(),
70
- subtrees: custom(v.array(v.string())).notNull()
71
- });
72
- const aggregateStorageTables = {
73
- [AGGREGATE_NODE_TABLE]: aggregateNodeTable,
74
- [AGGREGATE_TREE_TABLE]: aggregateTreeTable
75
- };
76
-
77
46
  //#endregion
78
47
  //#region src/aggregate-core/btree.ts
79
48
  const DEFAULT_MAX_NODE_SIZE = 16;
@@ -525,14 +494,21 @@ async function deleteTreeNodes(db, node) {
525
494
  }
526
495
  /**
527
496
  * Deletes up to `limit` nodes from one namespace tree belonging to an
528
- * aggregate, returning true once none are left. The traversal stack lives on
497
+ * aggregate, reporting `done` once none are left. The traversal stack lives on
529
498
  * the tree document so a large tree resumes across transactions.
499
+ *
500
+ * Nodes are dropped whatever they contain, so a caller clearing an aggregate
501
+ * never has to empty the tree key by key first.
530
502
  */
531
503
  async function deleteTreesHandler(ctx, args) {
532
504
  const tree = (await ctx.db.query(AGGREGATE_TREE_TABLE).withIndex("by_aggregate_name", (q) => q.eq("aggregateName", args.aggregateName)).take(1))[0];
533
- if (!tree) return true;
505
+ if (!tree) return {
506
+ done: true,
507
+ documents: 0
508
+ };
534
509
  const stack = [...tree.deletionStack ?? [tree.root]];
535
510
  let remaining = Math.max(1, Math.floor(args.limit));
511
+ let documents = 0;
536
512
  while (stack.length > 0 && remaining > 0) {
537
513
  const nodeId = stack.pop();
538
514
  const node = await ctx.db.get(nodeId);
@@ -540,10 +516,14 @@ async function deleteTreesHandler(ctx, args) {
540
516
  if (!node) continue;
541
517
  stack.push(...node.subtrees);
542
518
  await ctx.db.delete(nodeId);
519
+ documents += 1;
543
520
  }
544
521
  if (stack.length > 0) await ctx.db.patch(tree._id, { deletionStack: stack });
545
522
  else await ctx.db.delete(tree._id);
546
- return false;
523
+ return {
524
+ done: false,
525
+ documents: documents + 1
526
+ };
547
527
  }
548
528
  async function clearTree(db, args) {
549
529
  const tree = await getTree(db, args.namespace);
@@ -935,9 +915,10 @@ var Aggregate = class {
935
915
  });
936
916
  }
937
917
  /**
938
- * Deletes up to `limit` namespace trees without recreating them. Returns true
939
- * once this aggregate owns no trees, so callers can drain every namespace
940
- * across several mutations instead of walking them all in one.
918
+ * Deletes up to `limit` nodes from one namespace tree without recreating it,
919
+ * reporting `done` once this aggregate owns no trees and how many documents
920
+ * the call wrote. Callers drain every namespace across several mutations
921
+ * instead of walking them all in one, and charge their budget by `documents`.
941
922
  */
942
923
  async deleteTrees(ctx, limit) {
943
924
  return deleteTreesHandler({ db: ctx.db }, {
@@ -1077,4 +1058,4 @@ function namespaceFromOpts(opts) {
1077
1058
  }
1078
1059
 
1079
1060
  //#endregion
1080
- export { TableAggregate as n, aggregateStorageTables as r, DirectAggregate as t };
1061
+ export { TableAggregate as n, DirectAggregate as t };
@@ -0,0 +1,67 @@
1
+ import { b as ConvexColumnBuilder, f as text, g as custom, m as integer, s as index, t as convexTable, x as entityKind } from "./table-d9o_n4R3.js";
2
+ import { v } from "convex/values";
3
+
4
+ //#region src/orm/builders/id.ts
5
+ /**
6
+ * ID column builder class
7
+ * Compiles to v.id(tableName) or v.optional(v.id(tableName))
8
+ */
9
+ var ConvexIdBuilder = class extends ConvexColumnBuilder {
10
+ static [entityKind] = "ConvexIdBuilder";
11
+ constructor(name, tableName) {
12
+ super(name, "string", "ConvexId");
13
+ this.tableName = tableName;
14
+ this.config.referenceTable = tableName;
15
+ }
16
+ /**
17
+ * Expose Convex validator for schema integration
18
+ */
19
+ get convexValidator() {
20
+ if (this.config.notNull) return v.id(this.tableName);
21
+ return v.optional(v.union(v.null(), v.id(this.tableName)));
22
+ }
23
+ /**
24
+ * Compile to Convex validator
25
+ * .notNull() → v.id(tableName)
26
+ * nullable → v.optional(v.id(tableName))
27
+ */
28
+ build() {
29
+ return this.convexValidator;
30
+ }
31
+ };
32
+ function id(tableName) {
33
+ return new ConvexIdBuilder("", tableName);
34
+ }
35
+
36
+ //#endregion
37
+ //#region src/aggregate-core/schema.ts
38
+ const AGGREGATE_TREE_TABLE = "aggregate_rank_tree";
39
+ const AGGREGATE_NODE_TABLE = "aggregate_rank_node";
40
+ const aggregateCounterValidator = v.object({
41
+ count: v.number(),
42
+ sum: v.number()
43
+ });
44
+ const aggregateItemValidator = v.object({
45
+ k: v.any(),
46
+ v: v.any(),
47
+ s: v.number()
48
+ });
49
+ const aggregateTreeTable = convexTable(AGGREGATE_TREE_TABLE, {
50
+ aggregateName: text().notNull(),
51
+ deletionStack: custom(v.array(v.id(AGGREGATE_NODE_TABLE))),
52
+ maxNodeSize: integer().notNull(),
53
+ namespace: custom(v.any()),
54
+ root: id(AGGREGATE_NODE_TABLE).notNull()
55
+ }, (tree) => [index("by_namespace").on(tree.namespace), index("by_aggregate_name").on(tree.aggregateName)]);
56
+ const aggregateNodeTable = convexTable(AGGREGATE_NODE_TABLE, {
57
+ aggregate: custom(aggregateCounterValidator),
58
+ items: custom(v.array(aggregateItemValidator)).notNull(),
59
+ subtrees: custom(v.array(v.string())).notNull()
60
+ });
61
+ const aggregateStorageTables = {
62
+ [AGGREGATE_NODE_TABLE]: aggregateNodeTable,
63
+ [AGGREGATE_TREE_TABLE]: aggregateTreeTable
64
+ };
65
+
66
+ //#endregion
67
+ export { aggregateTreeTable as a, aggregateStorageTables as i, AGGREGATE_TREE_TABLE as n, id as o, aggregateNodeTable as r, AGGREGATE_NODE_TABLE as t };
@@ -1,100 +1,9 @@
1
- import { A as integer, C as index, N as json, O as text, P as objectOf, _ as TableDeleteConfig, a as Columns, j as arrayOf, s as OrmContext, t as convexTable, v as TableName, y as TablePolymorphic } from "./table-CX2lnX7e.js";
2
- import { t as id } from "./id-CuSfWa5q.js";
3
- import { C as matchLikePattern, _ as isFieldReference, d as filterValueInList, f as filterValuesEqual, u as fieldRef } from "./filter-expression-Dydt8wS0.js";
4
- import { t as defineSchemaExtension } from "./extensions-Blzsyekm.js";
1
+ import { _ as json, f as text, h as arrayOf, m as integer, s as index, t as convexTable, v as objectOf } from "./table-d9o_n4R3.js";
2
+ import { a as aggregateTreeTable, n as AGGREGATE_TREE_TABLE, r as aggregateNodeTable, t as AGGREGATE_NODE_TABLE } from "./schema-BFP_awgP.js";
3
+ import { g as TablePolymorphic, h as TableName, i as OrmContext, m as TableDeleteConfig, n as Columns } from "./symbols-DDNAddkd.js";
4
+ import { E as filterValuesEqual, L as matchLikePattern, T as filterValueInList, d as INTERNAL_CREATION_TIME_FIELD, f as PUBLIC_CREATED_AT_FIELD, j as isFieldReference, m as usesSystemCreatedAtAlias, n as findIndexForColumns, p as hasUserCreatedAtColumn, s as getIndexes, t as findExactIndexForColumns, u as CREATED_AT_MIGRATION_MESSAGE, w as fieldRef } from "./index-utils-C1DyktHe.js";
5
+ import { t as defineSchemaExtension } from "./extensions-Bp0XHanR.js";
5
6
 
6
- //#region src/orm/timestamp-mode.ts
7
- const PUBLIC_CREATED_AT_FIELD = "createdAt";
8
- const INTERNAL_CREATION_TIME_FIELD = "_creationTime";
9
- const CREATED_AT_MIGRATION_MESSAGE = "`_creationTime` is no longer public. Use `createdAt` instead.";
10
- const hasUserCreatedAtColumn = (table) => {
11
- if (!table || typeof table !== "object") return false;
12
- const columns = table[Columns];
13
- if (!columns || typeof columns !== "object") return false;
14
- return Object.hasOwn(columns, PUBLIC_CREATED_AT_FIELD);
15
- };
16
- const usesSystemCreatedAtAlias = (_table) => true;
17
-
18
- //#endregion
19
- //#region src/orm/index-utils.ts
20
- function getIndexes(table) {
21
- const indexes = table.getIndexes?.();
22
- return Array.isArray(indexes) ? indexes : [];
23
- }
24
- function getAggregateIndexes(table) {
25
- const indexes = table.getAggregateIndexes?.();
26
- return Array.isArray(indexes) ? indexes : [];
27
- }
28
- function getRankIndexes(table) {
29
- const indexes = table.getRankIndexes?.();
30
- return Array.isArray(indexes) ? indexes : [];
31
- }
32
- function getSearchIndexes(table) {
33
- const indexes = table.getSearchIndexes?.();
34
- return Array.isArray(indexes) ? indexes : [];
35
- }
36
- function findSearchIndexByName(table, indexName) {
37
- return getSearchIndexes(table).find((index) => index.name === indexName) ?? null;
38
- }
39
- function getVectorIndexes(table) {
40
- const indexes = table.getVectorIndexes?.();
41
- return Array.isArray(indexes) ? indexes : [];
42
- }
43
- function findVectorIndexByName(table, indexName) {
44
- return getVectorIndexes(table).find((index) => index.name === indexName) ?? null;
45
- }
46
- function findIndexForColumns(indexes, columns) {
47
- for (const index of indexes) if (hasColumnPrefix(index, columns)) return index.name;
48
- return null;
49
- }
50
- function findExactIndexForColumns(indexes, columns) {
51
- return indexes.find((candidate) => candidate.fields.length === columns.length && candidate.fields.every((field, position) => field === columns[position]))?.name ?? null;
52
- }
53
- const hasColumnPrefix = (index, columns) => {
54
- if (index.fields.length < columns.length) return false;
55
- for (let i = 0; i < columns.length; i += 1) if (index.fields[i] !== columns[i]) return false;
56
- return true;
57
- };
58
- /**
59
- * Answers "does scanning this index already produce the requested order?".
60
- *
61
- * Convex walks an index in full key order, so once a leading run of fields is
62
- * pinned to a single value by `eq`, the remainder of the scan is already sorted
63
- * by the next index field — and by `_creationTime` once every declared field is
64
- * pinned, because Convex appends it as the implicit trailing key. When that
65
- * field is the one the caller asked to sort by, `.order(dir).take(n)` returns
66
- * the exact page and nothing has to be collected and sorted afterwards.
67
- *
68
- * This is the single owner of that decision. The top-level query planner and
69
- * the relation loader both call it, so a bound one of them can push into the
70
- * index can never be one the other silently drops.
71
- *
72
- * Returns the direction to hand to `.order()`, or null when the sort must run
73
- * after the fetch.
74
- */
75
- function resolveIndexOrderPushdown(params) {
76
- const { indexFields, pinnedEqCount, orderSpecs } = params;
77
- if (!indexFields || orderSpecs.length !== 1) return null;
78
- const primary = orderSpecs[0];
79
- const eqCount = Math.min(Math.max(pinnedEqCount, 0), indexFields.length);
80
- for (let i = 0; i < eqCount; i += 1) if (indexFields[i] === primary.field) return primary.direction;
81
- const nativeField = eqCount >= indexFields.length ? INTERNAL_CREATION_TIME_FIELD : indexFields[eqCount];
82
- return primary.field === nativeField ? primary.direction : null;
83
- }
84
- function findRelationIndex(table, columns, relationName, targetTableName, strict = true, allowFullScan = false, orderSpecs = []) {
85
- const indexes = getIndexes(table);
86
- const fallbackIndex = findIndexForColumns(indexes, columns);
87
- const index = (orderSpecs.length === 0 ? void 0 : indexes.find((candidate) => hasColumnPrefix(candidate, columns) && resolveIndexOrderPushdown({
88
- indexFields: candidate.fields,
89
- pinnedEqCount: columns.length,
90
- orderSpecs
91
- }) !== null))?.name ?? fallbackIndex;
92
- if (!index && !allowFullScan) throw new Error(`Relation ${relationName} requires index on '${targetTableName}(${columns.join(", ")})'. Set allowFullScan: true to override.`);
93
- if (!index && strict) console.warn(`Relation ${relationName} running without index (allowFullScan: true).`);
94
- return index;
95
- }
96
-
97
- //#endregion
98
7
  //#region src/internal/concurrency.ts
99
8
  /**
100
9
  * Bounded-concurrency fan-out, shared by the ORM write path, relation loading
@@ -1435,9 +1344,11 @@ const getRankIndexDefinitions = (tableConfig) => {
1435
1344
  const AGGREGATE_BUCKET_TABLE = "aggregate_bucket";
1436
1345
  const AGGREGATE_MEMBER_TABLE = "aggregate_member";
1437
1346
  const AGGREGATE_EXTREMA_TABLE = "aggregate_extrema";
1438
- const AGGREGATE_RANK_TREE_TABLE = "aggregate_rank_tree";
1439
- const AGGREGATE_RANK_NODE_TABLE = "aggregate_rank_node";
1440
1347
  const AGGREGATE_STATE_TABLE = "aggregate_state";
1348
+ const AGGREGATE_RANK_TREE_TABLE = AGGREGATE_TREE_TABLE;
1349
+ const AGGREGATE_RANK_NODE_TABLE = AGGREGATE_NODE_TABLE;
1350
+ const rankTreeTable = aggregateTreeTable;
1351
+ const rankNodeTable = aggregateNodeTable;
1441
1352
  /**
1442
1353
  * Partition key a rank index's btree rows are stored under. Lives next to the
1443
1354
  * table names because it is how `AGGREGATE_RANK_TREE_TABLE` is addressed, and
@@ -1502,24 +1413,6 @@ const countStateTable = convexTable(AGGREGATE_STATE_TABLE, {
1502
1413
  index("by_kind_status").on(t.kind, t.status),
1503
1414
  index("by_table_status").on(t.tableKey, t.status)
1504
1415
  ]);
1505
- const rankTreeTable = convexTable(AGGREGATE_RANK_TREE_TABLE, {
1506
- aggregateName: text().notNull(),
1507
- maxNodeSize: integer().notNull(),
1508
- namespace: json(),
1509
- root: id(AGGREGATE_RANK_NODE_TABLE).notNull()
1510
- }, (tree) => [index("by_namespace").on(tree.namespace), index("by_aggregate_name").on(tree.aggregateName)]);
1511
- const rankNodeTable = convexTable(AGGREGATE_RANK_NODE_TABLE, {
1512
- aggregate: objectOf({
1513
- count: integer().notNull(),
1514
- sum: integer().notNull()
1515
- }),
1516
- items: arrayOf(objectOf({
1517
- k: json(),
1518
- v: json(),
1519
- s: integer().notNull()
1520
- })).notNull(),
1521
- subtrees: arrayOf(text().notNull()).notNull()
1522
- });
1523
1416
  const aggregateStorageTables = {
1524
1417
  [AGGREGATE_BUCKET_TABLE]: countBucketTable,
1525
1418
  [AGGREGATE_MEMBER_TABLE]: countMemberTable,
@@ -1533,4 +1426,4 @@ function aggregateExtension() {
1533
1426
  }
1534
1427
 
1535
1428
  //#endregion
1536
- export { patchReferencingRows as $, enforcePolymorphicWrite as A, getForeignKeys as B, collectPrimaryIdLookupRows as C, getRankIndexes as Ct, encodeUndefinedDeep as D, PUBLIC_CREATED_AT_FIELD as Dt, deserializeFilterExpression as E, INTERNAL_CREATION_TIME_FIELD as Et, evaluateCheckConstraintTriState as F, getTableColumns as G, getMutationCollectionLimits as H, evaluateFilter as I, getUniqueIndexes as J, getTableDeleteConfig as K, extractPrimaryIdLookup as L, ensureDefaultColumns as M, ensureNonNullValues as N, enforceCheckConstraints as O, usesSystemCreatedAtAlias as Ot, ensureNullableColumns as P, normalizeTemporalComparableValue as Q, getChecks as R, collectMutationRowsBounded as S, getIndexes as St, decodeUndefinedDeep as T, CREATED_AT_MIGRATION_MESSAGE as Tt, getMutationExecutionMode as U, getMutationAsyncDelayMs as V, getOrmContext as W, hydrateDateFieldsForRead as X, hardDeleteRow as Y, normalizeDateFieldsForWrite as Z, applyDefaults as _, findIndexForColumns as _t, AGGREGATE_STATE_TABLE as a, splitReturningSelection as at, buildForeignKeyGraph as b, findVectorIndexByName as bt, getAggregateIndexDefinitions as c, toConvexFilter as ct, COUNT_ERROR as d, markLifecycleHookedTables as dt, resolveOrmRuntimeDefaults as et, createAggregateError as f, compileConvexFilter as ft, ensureCountAllowedForRls as g, findExactIndexForColumns as gt, ensureAggregateAllowedForRls as h, mapWithConcurrency as ht, AGGREGATE_RANK_TREE_TABLE as i, softDeleteRow as it, enforceUniqueIndexes as j, enforceForeignKeys as k, getRankIndexDefinitions as l, unsetFieldsOf as lt, createError as m, isConvexEnforceableFilter as mt, AGGREGATE_EXTREMA_TABLE as n, selectReturningRowWithHydration as nt, aggregateExtension as o, stripUnsetFields as ot, createCountError as p, convexAnd as pt, getTableName as q, AGGREGATE_MEMBER_TABLE as r, serializeFilterExpression as rt, rankAggregateName as s, takeRowsWithinByteBudget as st, AGGREGATE_BUCKET_TABLE as t, returningSelectionReadsCreationTime as tt, AGGREGATE_ERROR as u, hasLifecycleHooks as ut, applyIncomingForeignKeyActionsOnDelete as v, findRelationIndex as vt, createForeignKeyProbeMemo as w, resolveIndexOrderPushdown as wt, canUsePrimaryIdLookupCursor as x, getAggregateIndexes as xt, applyIncomingForeignKeyActionsOnUpdate as y, findSearchIndexByName as yt, getColumnName as z };
1429
+ export { patchReferencingRows as $, enforcePolymorphicWrite as A, getForeignKeys as B, collectPrimaryIdLookupRows as C, encodeUndefinedDeep as D, deserializeFilterExpression as E, evaluateCheckConstraintTriState as F, getTableColumns as G, getMutationCollectionLimits as H, evaluateFilter as I, getUniqueIndexes as J, getTableDeleteConfig as K, extractPrimaryIdLookup as L, ensureDefaultColumns as M, ensureNonNullValues as N, enforceCheckConstraints as O, ensureNullableColumns as P, normalizeTemporalComparableValue as Q, getChecks as R, collectMutationRowsBounded as S, decodeUndefinedDeep as T, getMutationExecutionMode as U, getMutationAsyncDelayMs as V, getOrmContext as W, hydrateDateFieldsForRead as X, hardDeleteRow as Y, normalizeDateFieldsForWrite as Z, applyDefaults as _, AGGREGATE_STATE_TABLE as a, splitReturningSelection as at, buildForeignKeyGraph as b, getAggregateIndexDefinitions as c, toConvexFilter as ct, COUNT_ERROR as d, markLifecycleHookedTables as dt, resolveOrmRuntimeDefaults as et, createAggregateError as f, compileConvexFilter as ft, ensureCountAllowedForRls as g, ensureAggregateAllowedForRls as h, mapWithConcurrency as ht, AGGREGATE_RANK_TREE_TABLE as i, softDeleteRow as it, enforceUniqueIndexes as j, enforceForeignKeys as k, getRankIndexDefinitions as l, unsetFieldsOf as lt, createError as m, isConvexEnforceableFilter as mt, AGGREGATE_EXTREMA_TABLE as n, selectReturningRowWithHydration as nt, aggregateExtension as o, stripUnsetFields as ot, createCountError as p, convexAnd as pt, getTableName as q, AGGREGATE_MEMBER_TABLE as r, serializeFilterExpression as rt, rankAggregateName as s, takeRowsWithinByteBudget as st, AGGREGATE_BUCKET_TABLE as t, returningSelectionReadsCreationTime as tt, AGGREGATE_ERROR as u, hasLifecycleHooks as ut, applyIncomingForeignKeyActionsOnDelete as v, createForeignKeyProbeMemo as w, canUsePrimaryIdLookupCursor as x, applyIncomingForeignKeyActionsOnUpdate as y, getColumnName as z };