kitcn 0.26.2 → 0.26.3
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 +31 -0
- package/dist/aggregate/index.d.ts +2 -2
- package/dist/{capabilities-DtDfpdcH.d.ts → capabilities-QNGgWHQd.d.ts} +10 -0
- package/dist/orm/aggregate-index/index.d.ts +1 -1
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +3 -3
- package/dist/orm/migrations/index.d.ts +2 -2
- package/dist/{where-clause-compiler-eTewPUGq.d.ts → where-clause-compiler-DfFcNKtn.d.ts} +53 -53
- package/package.json +1 -1
- package/skills/kitcn/references/features/orm.md +25 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# kitcn
|
|
2
2
|
|
|
3
|
+
## 0.26.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#394](https://github.com/udecode/kitcn/pull/394) [`1317349`](https://github.com/udecode/kitcn/commit/13173495fa8db3d8a0568642981c1cdef4dcdf2b) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Features
|
|
8
|
+
|
|
9
|
+
- Support a per-source `index: { name, range }` on `select().union([...])`, so each source walks its own index range instead of re-walking one shared range and filtering the misses in JS.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const page = await db.query.messages
|
|
13
|
+
.select()
|
|
14
|
+
.union([
|
|
15
|
+
{
|
|
16
|
+
index: {
|
|
17
|
+
name: "by_from_to",
|
|
18
|
+
range: (q) => q.eq("from", me).eq("to", them),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
index: {
|
|
23
|
+
name: "by_from_to",
|
|
24
|
+
range: (q) => q.eq("from", them).eq("to", me),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
])
|
|
28
|
+
.interleaveBy(["createdAt", "id"])
|
|
29
|
+
.paginate({ cursor: null, limit: 20 });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- Support union sources anchored on different indexes, as long as each source pins its leading fields with `eq` and ends up ordered by the `interleaveBy` fields.
|
|
33
|
+
|
|
3
34
|
## 0.26.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bn as ConvexTextBuilderInitial, Xt as ConvexTableWithColumns } from "../capabilities-
|
|
2
|
-
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-
|
|
1
|
+
import { Bn as ConvexTextBuilderInitial, Xt as ConvexTableWithColumns } from "../capabilities-QNGgWHQd.js";
|
|
2
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-DfFcNKtn.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";
|
|
@@ -1430,6 +1430,16 @@ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y
|
|
|
1430
1430
|
type Merge<A, B> = { [K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never };
|
|
1431
1431
|
type IndexKey = (Value | undefined)[];
|
|
1432
1432
|
type FindManyUnionSource<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = {
|
|
1433
|
+
/**
|
|
1434
|
+
* Index anchor for this source alone. Overrides the chain-level
|
|
1435
|
+
* `.withIndex(...)`, so each source can walk its own range instead of
|
|
1436
|
+
* re-walking one shared range and discarding the misses in JS.
|
|
1437
|
+
*
|
|
1438
|
+
* Sources may pin different indexes: `interleaveBy` re-orders every source by
|
|
1439
|
+
* the same trailing fields before merging, so what has to match across
|
|
1440
|
+
* sources is that ordering suffix, not the index name.
|
|
1441
|
+
*/
|
|
1442
|
+
index?: PredicateWhereIndexConfig<TTableConfig>;
|
|
1433
1443
|
where?: RelationsFilter<TTableConfig, any> | WhereCallback<TTableConfig>;
|
|
1434
1444
|
};
|
|
1435
1445
|
type PipelineRelationName<TTableConfig extends TableRelationalConfig> = Extract<keyof TTableConfig['relations'], string>;
|
|
@@ -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-
|
|
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-QNGgWHQd.js";
|
|
2
2
|
|
|
3
3
|
//#region src/orm/aggregate-index/capability.d.ts
|
|
4
4
|
/**
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
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-QNGgWHQd.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-DfFcNKtn.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
|
@@ -2675,16 +2675,16 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
2675
2675
|
return streamQuery;
|
|
2676
2676
|
}
|
|
2677
2677
|
_buildUnionSourceStream(source, fallbackOrder) {
|
|
2678
|
-
const
|
|
2678
|
+
const sourceIndex = source.index ?? this.configuredIndex;
|
|
2679
2679
|
this._assertWhereIndexRequirement({
|
|
2680
2680
|
where: source.where,
|
|
2681
2681
|
tableConfig: this.tableConfig,
|
|
2682
|
-
hasConfiguredIndex: Boolean(
|
|
2682
|
+
hasConfiguredIndex: Boolean(sourceIndex?.name),
|
|
2683
2683
|
context: "pipeline.union source"
|
|
2684
2684
|
});
|
|
2685
2685
|
const schemaDefinition = this._getSchemaDefinitionOrThrow();
|
|
2686
2686
|
let sourceStream = stream(this.db, schemaDefinition).query(this.tableConfig.name);
|
|
2687
|
-
if (
|
|
2687
|
+
if (sourceIndex?.name) sourceStream = sourceStream.withIndex(sourceIndex.name, sourceIndex.range ? sourceIndex.range : (q) => q);
|
|
2688
2688
|
sourceStream = sourceStream.order(fallbackOrder);
|
|
2689
2689
|
const sourcePredicate = this._buildTableFilterPredicate(source.where, this.tableConfig);
|
|
2690
2690
|
if (sourcePredicate) sourceStream = sourceStream.filterWith(sourcePredicate);
|
|
@@ -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-
|
|
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-
|
|
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-QNGgWHQd.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-DfFcNKtn.js";
|
|
3
3
|
export { MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bn as ConvexTextBuilderInitial, Dr as SystemFieldAliases, F as DeleteMode, Gn as OrmRuntimeDefaults, H as EdgeMetadata, Hn as ConvexColumnBuilder, Hr as entityKind, Ht as RelationsConfigWithSchema, I as SerializedFilterExpression, Jn as OrmSchemaExtensionTriggers, Kn as OrmSchemaExtensionRelations, L as getChecks, M as OrmReader, Mr as ColumnBuilderBaseConfig, N as OrmWriter, Nt as AnyRelationsBuilderConfig, Or as SystemFields, P as CascadeMode, Pt as ExtractTablesFromSchema, Qt as OrmLifecycleChange, R as getForeignKeys, Rr as HasDefault, Rt as RelationsBuilder, St as OrderByClause, Ut as TableRelationalConfig, Vt as RelationsBuilderConfigValue, Wn as Columns, Wt as TablesRelationalConfig, Xn as OrmSchemaRelations, Xt as ConvexTableWithColumns, Yt as ConvexTable, Zn as OrmSchemaTriggers, b as MigrationSet, ft as InferSelectModel, in as RlsPolicy, jr as ColumnBuilder, jt as VectorSearchProvider, k as CreateDatabaseOptions, kr as $Type, nr as FilterExpression$1, r as OrmCapability, ut as InferInsertModel, z as getUniqueIndexes } from "./capabilities-
|
|
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-QNGgWHQd.js";
|
|
2
2
|
import * as convex_values0 from "convex/values";
|
|
3
3
|
import { GenericId, Validator, Value } from "convex/values";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchedulableFunctionReference, Scheduler, SchemaDefinition, internalActionGeneric, internalMutationGeneric } from "convex/server";
|
|
@@ -120,6 +120,19 @@ declare const migrationStorageTables: {
|
|
|
120
120
|
fieldName: "direction";
|
|
121
121
|
};
|
|
122
122
|
};
|
|
123
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
124
|
+
_: {
|
|
125
|
+
notNull: true;
|
|
126
|
+
};
|
|
127
|
+
} & {
|
|
128
|
+
_: {
|
|
129
|
+
tableName: "migration_state";
|
|
130
|
+
};
|
|
131
|
+
} & {
|
|
132
|
+
_: {
|
|
133
|
+
fieldName: "updatedAt";
|
|
134
|
+
};
|
|
135
|
+
};
|
|
123
136
|
migrationId: ConvexTextBuilderInitial<""> & {
|
|
124
137
|
_: {
|
|
125
138
|
notNull: true;
|
|
@@ -190,19 +203,6 @@ declare const migrationStorageTables: {
|
|
|
190
203
|
fieldName: "startedAt";
|
|
191
204
|
};
|
|
192
205
|
};
|
|
193
|
-
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
194
|
-
_: {
|
|
195
|
-
notNull: true;
|
|
196
|
-
};
|
|
197
|
-
} & {
|
|
198
|
-
_: {
|
|
199
|
-
tableName: "migration_state";
|
|
200
|
-
};
|
|
201
|
-
} & {
|
|
202
|
-
_: {
|
|
203
|
-
fieldName: "updatedAt";
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
206
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
|
207
207
|
_: {
|
|
208
208
|
tableName: "migration_state";
|
|
@@ -269,7 +269,7 @@ declare const migrationStorageTables: {
|
|
|
269
269
|
fieldName: "direction";
|
|
270
270
|
};
|
|
271
271
|
};
|
|
272
|
-
|
|
272
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
273
273
|
_: {
|
|
274
274
|
notNull: true;
|
|
275
275
|
};
|
|
@@ -279,10 +279,10 @@ declare const migrationStorageTables: {
|
|
|
279
279
|
};
|
|
280
280
|
} & {
|
|
281
281
|
_: {
|
|
282
|
-
fieldName: "
|
|
282
|
+
fieldName: "updatedAt";
|
|
283
283
|
};
|
|
284
284
|
};
|
|
285
|
-
|
|
285
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
286
286
|
_: {
|
|
287
287
|
notNull: true;
|
|
288
288
|
};
|
|
@@ -292,10 +292,10 @@ declare const migrationStorageTables: {
|
|
|
292
292
|
};
|
|
293
293
|
} & {
|
|
294
294
|
_: {
|
|
295
|
-
fieldName: "
|
|
295
|
+
fieldName: "runId";
|
|
296
296
|
};
|
|
297
297
|
};
|
|
298
|
-
|
|
298
|
+
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
299
299
|
_: {
|
|
300
300
|
notNull: true;
|
|
301
301
|
};
|
|
@@ -305,7 +305,7 @@ declare const migrationStorageTables: {
|
|
|
305
305
|
};
|
|
306
306
|
} & {
|
|
307
307
|
_: {
|
|
308
|
-
fieldName: "
|
|
308
|
+
fieldName: "startedAt";
|
|
309
309
|
};
|
|
310
310
|
};
|
|
311
311
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
|
@@ -1008,7 +1008,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1008
1008
|
readonly aggregate_bucket: ConvexTableWithColumns<{
|
|
1009
1009
|
name: "aggregate_bucket";
|
|
1010
1010
|
columns: {
|
|
1011
|
-
|
|
1011
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
1012
1012
|
_: {
|
|
1013
1013
|
notNull: true;
|
|
1014
1014
|
};
|
|
@@ -1018,10 +1018,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1018
1018
|
};
|
|
1019
1019
|
} & {
|
|
1020
1020
|
_: {
|
|
1021
|
-
fieldName: "
|
|
1021
|
+
fieldName: "count";
|
|
1022
1022
|
};
|
|
1023
1023
|
};
|
|
1024
|
-
|
|
1024
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1025
1025
|
_: {
|
|
1026
1026
|
notNull: true;
|
|
1027
1027
|
};
|
|
@@ -1031,7 +1031,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1031
1031
|
};
|
|
1032
1032
|
} & {
|
|
1033
1033
|
_: {
|
|
1034
|
-
fieldName: "
|
|
1034
|
+
fieldName: "updatedAt";
|
|
1035
1035
|
};
|
|
1036
1036
|
};
|
|
1037
1037
|
indexName: ConvexTextBuilderInitial<""> & {
|
|
@@ -1340,7 +1340,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1340
1340
|
fieldName: "value";
|
|
1341
1341
|
};
|
|
1342
1342
|
};
|
|
1343
|
-
|
|
1343
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
1344
1344
|
_: {
|
|
1345
1345
|
notNull: true;
|
|
1346
1346
|
};
|
|
@@ -1350,10 +1350,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1350
1350
|
};
|
|
1351
1351
|
} & {
|
|
1352
1352
|
_: {
|
|
1353
|
-
fieldName: "
|
|
1353
|
+
fieldName: "count";
|
|
1354
1354
|
};
|
|
1355
1355
|
};
|
|
1356
|
-
|
|
1356
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1357
1357
|
_: {
|
|
1358
1358
|
notNull: true;
|
|
1359
1359
|
};
|
|
@@ -1363,7 +1363,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1363
1363
|
};
|
|
1364
1364
|
} & {
|
|
1365
1365
|
_: {
|
|
1366
|
-
fieldName: "
|
|
1366
|
+
fieldName: "updatedAt";
|
|
1367
1367
|
};
|
|
1368
1368
|
};
|
|
1369
1369
|
indexName: ConvexTextBuilderInitial<""> & {
|
|
@@ -1611,7 +1611,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1611
1611
|
fieldName: "cursor";
|
|
1612
1612
|
};
|
|
1613
1613
|
};
|
|
1614
|
-
|
|
1614
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1615
1615
|
_: {
|
|
1616
1616
|
notNull: true;
|
|
1617
1617
|
};
|
|
@@ -1621,10 +1621,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1621
1621
|
};
|
|
1622
1622
|
} & {
|
|
1623
1623
|
_: {
|
|
1624
|
-
fieldName: "
|
|
1624
|
+
fieldName: "updatedAt";
|
|
1625
1625
|
};
|
|
1626
1626
|
};
|
|
1627
|
-
|
|
1627
|
+
processed: ConvexNumberBuilderInitial<""> & {
|
|
1628
1628
|
_: {
|
|
1629
1629
|
notNull: true;
|
|
1630
1630
|
};
|
|
@@ -1634,10 +1634,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1634
1634
|
};
|
|
1635
1635
|
} & {
|
|
1636
1636
|
_: {
|
|
1637
|
-
fieldName: "
|
|
1637
|
+
fieldName: "processed";
|
|
1638
1638
|
};
|
|
1639
1639
|
};
|
|
1640
|
-
|
|
1640
|
+
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
1641
1641
|
_: {
|
|
1642
1642
|
notNull: true;
|
|
1643
1643
|
};
|
|
@@ -1647,7 +1647,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1647
1647
|
};
|
|
1648
1648
|
} & {
|
|
1649
1649
|
_: {
|
|
1650
|
-
fieldName: "
|
|
1650
|
+
fieldName: "startedAt";
|
|
1651
1651
|
};
|
|
1652
1652
|
};
|
|
1653
1653
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
|
@@ -1762,6 +1762,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1762
1762
|
fieldName: "direction";
|
|
1763
1763
|
};
|
|
1764
1764
|
};
|
|
1765
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1766
|
+
_: {
|
|
1767
|
+
notNull: true;
|
|
1768
|
+
};
|
|
1769
|
+
} & {
|
|
1770
|
+
_: {
|
|
1771
|
+
tableName: "migration_state";
|
|
1772
|
+
};
|
|
1773
|
+
} & {
|
|
1774
|
+
_: {
|
|
1775
|
+
fieldName: "updatedAt";
|
|
1776
|
+
};
|
|
1777
|
+
};
|
|
1765
1778
|
migrationId: ConvexTextBuilderInitial<""> & {
|
|
1766
1779
|
_: {
|
|
1767
1780
|
notNull: true;
|
|
@@ -1832,19 +1845,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1832
1845
|
fieldName: "startedAt";
|
|
1833
1846
|
};
|
|
1834
1847
|
};
|
|
1835
|
-
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1836
|
-
_: {
|
|
1837
|
-
notNull: true;
|
|
1838
|
-
};
|
|
1839
|
-
} & {
|
|
1840
|
-
_: {
|
|
1841
|
-
tableName: "migration_state";
|
|
1842
|
-
};
|
|
1843
|
-
} & {
|
|
1844
|
-
_: {
|
|
1845
|
-
fieldName: "updatedAt";
|
|
1846
|
-
};
|
|
1847
|
-
};
|
|
1848
1848
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
|
1849
1849
|
_: {
|
|
1850
1850
|
tableName: "migration_state";
|
|
@@ -1911,7 +1911,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1911
1911
|
fieldName: "direction";
|
|
1912
1912
|
};
|
|
1913
1913
|
};
|
|
1914
|
-
|
|
1914
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1915
1915
|
_: {
|
|
1916
1916
|
notNull: true;
|
|
1917
1917
|
};
|
|
@@ -1921,10 +1921,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1921
1921
|
};
|
|
1922
1922
|
} & {
|
|
1923
1923
|
_: {
|
|
1924
|
-
fieldName: "
|
|
1924
|
+
fieldName: "updatedAt";
|
|
1925
1925
|
};
|
|
1926
1926
|
};
|
|
1927
|
-
|
|
1927
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
1928
1928
|
_: {
|
|
1929
1929
|
notNull: true;
|
|
1930
1930
|
};
|
|
@@ -1934,10 +1934,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1934
1934
|
};
|
|
1935
1935
|
} & {
|
|
1936
1936
|
_: {
|
|
1937
|
-
fieldName: "
|
|
1937
|
+
fieldName: "runId";
|
|
1938
1938
|
};
|
|
1939
1939
|
};
|
|
1940
|
-
|
|
1940
|
+
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
1941
1941
|
_: {
|
|
1942
1942
|
notNull: true;
|
|
1943
1943
|
};
|
|
@@ -1947,7 +1947,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1947
1947
|
};
|
|
1948
1948
|
} & {
|
|
1949
1949
|
_: {
|
|
1950
|
-
fieldName: "
|
|
1950
|
+
fieldName: "startedAt";
|
|
1951
1951
|
};
|
|
1952
1952
|
};
|
|
1953
1953
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
package/package.json
CHANGED
|
@@ -543,45 +543,47 @@ return await ctx.orm.query.articles.findMany({
|
|
|
543
543
|
|
|
544
544
|
```ts
|
|
545
545
|
return await ctx.orm.query.messages
|
|
546
|
-
.withIndex("by_from_to")
|
|
547
|
-
.select()
|
|
548
|
-
.union([
|
|
549
|
-
{ where: { from: input.me, to: input.them } },
|
|
550
|
-
{ where: { from: input.them, to: input.me } },
|
|
551
|
-
])
|
|
552
|
-
.interleaveBy(["createdAt", "id"])
|
|
553
|
-
.filter(async (m) => !m.deletedAt)
|
|
554
|
-
.map(async (m) => ({ ...m, body: m.body.slice(0, 240) }))
|
|
555
|
-
.paginate({
|
|
556
|
-
cursor: input.cursor,
|
|
557
|
-
limit: input.limit,
|
|
558
|
-
maxScan: 500,
|
|
559
|
-
});
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
### Union with index ranges
|
|
563
|
-
|
|
564
|
-
```ts
|
|
565
|
-
const page = await ctx.orm.query.messages
|
|
566
546
|
.select()
|
|
567
547
|
.union([
|
|
568
548
|
{
|
|
569
549
|
index: {
|
|
570
550
|
name: "by_from_to",
|
|
571
|
-
range: (q) => q.eq("from", me).eq("to", them),
|
|
551
|
+
range: (q) => q.eq("from", input.me).eq("to", input.them),
|
|
572
552
|
},
|
|
573
553
|
},
|
|
574
554
|
{
|
|
575
555
|
index: {
|
|
576
556
|
name: "by_from_to",
|
|
577
|
-
range: (q) => q.eq("from", them).eq("to", me),
|
|
557
|
+
range: (q) => q.eq("from", input.them).eq("to", input.me),
|
|
578
558
|
},
|
|
579
559
|
},
|
|
580
560
|
])
|
|
581
561
|
.interleaveBy(["createdAt", "id"])
|
|
582
|
-
.
|
|
562
|
+
.filter(async (m) => !m.deletedAt)
|
|
563
|
+
.map(async (m) => ({ ...m, body: m.body.slice(0, 240) }))
|
|
564
|
+
.paginate({
|
|
565
|
+
cursor: input.cursor,
|
|
566
|
+
limit: input.limit,
|
|
567
|
+
maxScan: 500,
|
|
568
|
+
});
|
|
583
569
|
```
|
|
584
570
|
|
|
571
|
+
Per source:
|
|
572
|
+
|
|
573
|
+
- `index: { name, range }` anchors that source on its own range. It overrides
|
|
574
|
+
the chain-level `.withIndex(...)`; sources that omit it use the chain index.
|
|
575
|
+
- `where` filters that source's rows after the read.
|
|
576
|
+
|
|
577
|
+
`interleaveBy` fields must be the trailing fields each source is already ordered
|
|
578
|
+
by, so every field before them has to be pinned with `eq` in that source's
|
|
579
|
+
range. Sources may name different indexes when they land on the same trailing
|
|
580
|
+
fields — e.g. `by_author_likes` (authorId, numLikes) with `eq("authorId", ...)`
|
|
581
|
+
merges with `numLikesAndType` (type, numLikes) with `eq("type", ...)` under
|
|
582
|
+
`interleaveBy(["numLikes"])`.
|
|
583
|
+
|
|
584
|
+
Anchor every source. A shared `.withIndex(...)` plus per-source `where` makes
|
|
585
|
+
each source walk the same range and discard the misses after reading them.
|
|
586
|
+
|
|
585
587
|
### Pre-pagination transforms
|
|
586
588
|
|
|
587
589
|
```ts
|