kitcn 0.25.2 → 0.25.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/dist/aggregate/index.d.ts +2 -2
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +5 -5
- package/dist/{capabilities-Bem7xvGK.d.ts → capabilities-DtDfpdcH.d.ts} +20 -1
- package/dist/{generated-contract-disabled-BEc4d98x.d.ts → generated-contract-disabled-SzH57bhp.d.ts} +1 -1
- package/dist/orm/aggregate-index/index.d.ts +1 -1
- package/dist/orm/aggregate-index/index.js +14 -3
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +52 -14
- package/dist/orm/migrations/index.d.ts +2 -2
- package/dist/{where-clause-compiler-TMNQB6US.d.ts → where-clause-compiler-Bke7ULoY.d.ts} +72 -72
- package/package.json +1 -1
- package/skills/kitcn/references/features/aggregates.md +3 -0
|
@@ -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-DtDfpdcH.js";
|
|
2
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-Bke7ULoY.js";
|
|
3
3
|
import * as convex_values0 from "convex/values";
|
|
4
4
|
import { GenericId, Infer, Value } from "convex/values";
|
|
5
5
|
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-
|
|
1
|
+
import { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-SzH57bhp.js";
|
|
2
2
|
export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-DJONf8X5.js";
|
|
2
2
|
import { t as GetAuth } from "../types-Bf3XQex5.js";
|
|
3
3
|
import { t as GenericCtx } from "../context-utils-DwZ3Cam1.js";
|
|
4
|
-
import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-
|
|
4
|
+
import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-SzH57bhp.js";
|
|
5
5
|
import * as convex_values0 from "convex/values";
|
|
6
6
|
import { Infer } from "convex/values";
|
|
7
7
|
import { AuthConfig, DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
|
|
@@ -134,8 +134,8 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
134
134
|
limit?: number | undefined;
|
|
135
135
|
offset?: number | undefined;
|
|
136
136
|
sortBy?: {
|
|
137
|
-
field: string;
|
|
138
137
|
direction: "asc" | "desc";
|
|
138
|
+
field: string;
|
|
139
139
|
} | undefined;
|
|
140
140
|
model: string;
|
|
141
141
|
}, {
|
|
@@ -144,12 +144,12 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
144
144
|
offset: convex_values0.VFloat64<number | undefined, "optional">;
|
|
145
145
|
select: convex_values0.VArray<string[] | undefined, convex_values0.VString<string, "required">, "optional">;
|
|
146
146
|
sortBy: convex_values0.VObject<{
|
|
147
|
-
field: string;
|
|
148
147
|
direction: "asc" | "desc";
|
|
148
|
+
field: string;
|
|
149
149
|
} | undefined, {
|
|
150
150
|
direction: convex_values0.VUnion<"asc" | "desc", [convex_values0.VLiteral<"asc", "required">, convex_values0.VLiteral<"desc", "required">], "required", never>;
|
|
151
151
|
field: convex_values0.VString<string, "required">;
|
|
152
|
-
}, "optional", "
|
|
152
|
+
}, "optional", "direction" | "field">;
|
|
153
153
|
where: convex_values0.VArray<{
|
|
154
154
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
155
155
|
connector?: "AND" | "OR" | undefined;
|
|
@@ -169,7 +169,7 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
169
169
|
operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
|
|
170
170
|
value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
|
|
171
171
|
}, "required", "mode" | "value" | "connector" | "field" | "operator">, "optional">;
|
|
172
|
-
}, "required", "model" | "select" | "where" | "limit" | "offset" | "sortBy" | "sortBy.
|
|
172
|
+
}, "required", "model" | "select" | "where" | "limit" | "offset" | "sortBy" | "sortBy.direction" | "sortBy.field">;
|
|
173
173
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
174
174
|
declare const checkUniqueFields: <Schema extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
|
|
175
175
|
declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
|
|
@@ -2139,7 +2139,7 @@ declare const createAggregateError: (code: AggregateErrorCode, message: string)
|
|
|
2139
2139
|
declare const ensureCountAllowedForRls: (tableConfig: TableRelationalConfig, rlsMode: "skip" | "default" | undefined) => void;
|
|
2140
2140
|
declare const ensureAggregateAllowedForRls: (tableConfig: TableRelationalConfig, rlsMode: "skip" | "default" | undefined, methodName: string) => void;
|
|
2141
2141
|
declare namespace runtime_d_exports$1 {
|
|
2142
|
-
export { AGGREGATE_ERROR, AGGREGATE_STATE_KIND_METRIC, AGGREGATE_STATE_KIND_RANK, AggregateBucketDelta, AggregateErrorCode, AggregateExtremaDelta, AggregateIndexDefinition, AggregateMemberWrite, AggregateMembershipDelta, AggregateQueryPlan, AggregateRangeConstraint, COUNT_ERROR, COUNT_STATUS_BUILDING, COUNT_STATUS_CLEARING, COUNT_STATUS_READY, ClearIndexChunkResult, CountErrorCode, CountIndexDefinition, CountQueryPlan, CountState, PlanBucketReadCache, applyAggregateIndexesForChange, applyCountIndexesForChange, asUnknownArray, assertAggregateIndexesWritable, clearCountIndexChunk, compileAggregateQueryPlan, compileCountFieldQueryPlan, compileCountQueryPlan, computeAggregateMembershipDelta, computeAggregateMetricValues, computeCountKeyParts, createAggregateError, createCountError, ensureAggregateAllowedForRls, ensureAggregateIndexReady, ensureCountAllowedForRls, ensureCountIndexReady, flushAggregateMembershipDeltas, getAggregateIndexDefinitions, getCountIndexDefinitions, getCountIndexValuesForFields, getCountState, isAggregatePlanZero, isIndexCountZero, listCountStates, listSchemaAggregateIndexes, listSchemaCountIndexes, parseAggregateWhere, parseCountWhere, readAverageFromBuckets, readCountFieldFromBuckets, readCountFromBuckets, readExtremaFromBuckets, readPlanBuckets, readSumFromBuckets, reconcileAggregateMembership, serializeCountKeyParts, setCountState, setCountStateError };
|
|
2142
|
+
export { AGGREGATE_ERROR, AGGREGATE_STATE_KIND_METRIC, AGGREGATE_STATE_KIND_RANK, AggregateBucketDelta, AggregateErrorCode, AggregateExtremaDelta, AggregateIndexDefinition, AggregateMemberWrite, AggregateMembershipDelta, AggregateQueryPlan, AggregateRangeConstraint, COUNT_ERROR, COUNT_STATUS_BUILDING, COUNT_STATUS_CLEARING, COUNT_STATUS_READY, ClearIndexChunkResult, CountErrorCode, CountIndexDefinition, CountQueryPlan, CountState, NULLISH_PROBE_VALUES, PlanBucketReadCache, applyAggregateIndexesForChange, applyCountIndexesForChange, asUnknownArray, assertAggregateIndexesWritable, clearCountIndexChunk, compileAggregateQueryPlan, compileCountFieldQueryPlan, compileCountQueryPlan, computeAggregateMembershipDelta, computeAggregateMetricValues, computeCountKeyParts, createAggregateError, createCountError, ensureAggregateAllowedForRls, ensureAggregateIndexReady, ensureCountAllowedForRls, ensureCountIndexReady, flushAggregateMembershipDeltas, getAggregateIndexDefinitions, getCountIndexDefinitions, getCountIndexValuesForFields, getCountState, isAggregatePlanZero, isIndexCountZero, listCountStates, listSchemaAggregateIndexes, listSchemaCountIndexes, parseAggregateWhere, parseCountWhere, readAverageFromBuckets, readCountFieldFromBuckets, readCountFromBuckets, readExtremaFromBuckets, readPlanBuckets, readSumFromBuckets, reconcileAggregateMembership, serializeCountKeyParts, setCountState, setCountStateError };
|
|
2143
2143
|
}
|
|
2144
2144
|
declare const AGGREGATE_STATE_KIND_METRIC = "metric";
|
|
2145
2145
|
declare const AGGREGATE_STATE_KIND_RANK = "rank";
|
|
@@ -2216,6 +2216,17 @@ type AggregateQueryPlan = {
|
|
|
2216
2216
|
metric: AggregateMetricRequest;
|
|
2217
2217
|
};
|
|
2218
2218
|
type PlanBucketReadCache = Map<string, Promise<unknown[]>>;
|
|
2219
|
+
/**
|
|
2220
|
+
* A nullable column is `v.optional(v.union(v.null(), ...))`, so a row that
|
|
2221
|
+
* never had the column written stores it absent, and `computeCountKeyParts`
|
|
2222
|
+
* encodes absent as the `__kitcnUndefined` sentinel — a different bucket from
|
|
2223
|
+
* the one an explicit `null` lands in. `isNull` means null-or-absent
|
|
2224
|
+
* everywhere else in the ORM, so probing only the `null` bucket silently
|
|
2225
|
+
* undercounts every row written before the column existed. Both probes are
|
|
2226
|
+
* looked up through `serializeStable`, which maps `undefined` onto the same
|
|
2227
|
+
* sentinel the write path stored.
|
|
2228
|
+
*/
|
|
2229
|
+
declare const NULLISH_PROBE_VALUES: readonly unknown[];
|
|
2219
2230
|
declare const serializeCountKeyParts: (parts: unknown[]) => string;
|
|
2220
2231
|
declare const compileCountQueryPlan: (tableConfig: TableRelationalConfig, where: unknown) => CountQueryPlan;
|
|
2221
2232
|
declare const compileCountFieldQueryPlan: (tableConfig: TableRelationalConfig, where: unknown, field: string) => AggregateQueryPlan;
|
|
@@ -3030,6 +3041,14 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
|
|
|
3030
3041
|
private _pushGroupByConstraint;
|
|
3031
3042
|
private _parseGroupByFieldConstraint;
|
|
3032
3043
|
private _collectGroupByFieldValues;
|
|
3044
|
+
/**
|
|
3045
|
+
* One group per distinct value, where `null` and absent count as the same
|
|
3046
|
+
* value. They occupy different aggregate buckets, so the emitted group key
|
|
3047
|
+
* and the filter that reads it diverge: the key reports `null` while the
|
|
3048
|
+
* filter keeps `isNull` so the aggregate compiler reads both buckets and
|
|
3049
|
+
* combines their metrics into a single row.
|
|
3050
|
+
*/
|
|
3051
|
+
private _buildGroupBySlots;
|
|
3033
3052
|
private _buildGroupByCandidates;
|
|
3034
3053
|
private _coerceGroupByByFields;
|
|
3035
3054
|
private _isGroupByOrderDirection;
|
package/dist/{generated-contract-disabled-BEc4d98x.d.ts → generated-contract-disabled-SzH57bhp.d.ts}
RENAMED
|
@@ -235,8 +235,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
235
235
|
limit?: number | undefined;
|
|
236
236
|
offset?: number | undefined;
|
|
237
237
|
sortBy?: {
|
|
238
|
-
field: string;
|
|
239
238
|
direction: "asc" | "desc";
|
|
239
|
+
field: string;
|
|
240
240
|
} | undefined;
|
|
241
241
|
model: string;
|
|
242
242
|
paginationOpts: {
|
|
@@ -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-DtDfpdcH.js";
|
|
2
2
|
|
|
3
3
|
//#region src/orm/aggregate-index/capability.d.ts
|
|
4
4
|
/**
|
|
@@ -27,6 +27,17 @@ const normalizeUndefined = (value) => {
|
|
|
27
27
|
return value;
|
|
28
28
|
};
|
|
29
29
|
const serializeStable = (value) => JSON.stringify(normalizeUndefined(value));
|
|
30
|
+
/**
|
|
31
|
+
* A nullable column is `v.optional(v.union(v.null(), ...))`, so a row that
|
|
32
|
+
* never had the column written stores it absent, and `computeCountKeyParts`
|
|
33
|
+
* encodes absent as the `__kitcnUndefined` sentinel — a different bucket from
|
|
34
|
+
* the one an explicit `null` lands in. `isNull` means null-or-absent
|
|
35
|
+
* everywhere else in the ORM, so probing only the `null` bucket silently
|
|
36
|
+
* undercounts every row written before the column existed. Both probes are
|
|
37
|
+
* looked up through `serializeStable`, which maps `undefined` onto the same
|
|
38
|
+
* sentinel the write path stored.
|
|
39
|
+
*/
|
|
40
|
+
const NULLISH_PROBE_VALUES = [null, void 0];
|
|
30
41
|
const toConstraintSet = (values) => {
|
|
31
42
|
const set = /* @__PURE__ */ new Map();
|
|
32
43
|
for (const value of values) set.set(serializeStable(value), value);
|
|
@@ -138,7 +149,7 @@ const parseFieldFilter = (tableConfig, fieldName, value, target, codes, methodNa
|
|
|
138
149
|
if (Object.hasOwn(filter, "isNull")) {
|
|
139
150
|
hasRecognizedOperator = true;
|
|
140
151
|
if (filter.isNull !== true) throw createFilterError(codes, methodName, `field '${fieldName}'.isNull only supports true.`);
|
|
141
|
-
pushConstraint(target, fieldName, [
|
|
152
|
+
pushConstraint(target, fieldName, [...NULLISH_PROBE_VALUES]);
|
|
142
153
|
}
|
|
143
154
|
for (const operator of [
|
|
144
155
|
"gt",
|
|
@@ -405,9 +416,9 @@ const enforceCartesianExpansionGuards = (options) => {
|
|
|
405
416
|
const maxTrackedCombinations = Math.max(cartesianMaxKeys, maxCombinationsByWork);
|
|
406
417
|
const combinations = countCartesianCombinations(options.fields, options.fieldValues, maxTrackedCombinations);
|
|
407
418
|
if (combinations === 0) return;
|
|
408
|
-
if (combinations > cartesianMaxKeys) throw createFilterError(options.codes, options.methodName, `expands
|
|
419
|
+
if (combinations > cartesianMaxKeys) throw createFilterError(options.codes, options.methodName, `expands to ${combinations} key combinations on aggregateIndex '${options.indexName}', exceeding aggregateCartesianMaxKeys (${cartesianMaxKeys}). Each 'in' value and each 'isNull' field (which reads both the null and the absent key) multiplies the combinations. Reduce IN list sizes, split the query, add a narrower aggregateIndex, or increase defineSchema(..., { defaults: { aggregateCartesianMaxKeys } }).`);
|
|
409
420
|
const estimatedWork = combinations * workUnitsPerCombination;
|
|
410
|
-
if (estimatedWork > workBudget) throw createFilterError(options.codes, options.methodName, `estimated ${options.workLabel} is ${estimatedWork} units on aggregateIndex '${options.indexName}', exceeding aggregateWorkBudget (${workBudget}). Reduce IN fan-out, split the query, or increase defineSchema(..., { defaults: { aggregateWorkBudget } }).`);
|
|
421
|
+
if (estimatedWork > workBudget) throw createFilterError(options.codes, options.methodName, `estimated ${options.workLabel} is ${estimatedWork} units on aggregateIndex '${options.indexName}', exceeding aggregateWorkBudget (${workBudget}). Reduce IN or isNull fan-out, split the query, or increase defineSchema(..., { defaults: { aggregateWorkBudget } }).`);
|
|
411
422
|
};
|
|
412
423
|
const hasLogicalOr = (where) => {
|
|
413
424
|
if (Object.hasOwn(where, "OR")) return true;
|
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-DtDfpdcH.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-Bke7ULoY.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
|
@@ -3218,7 +3218,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3218
3218
|
if (Object.hasOwn(filter, "isNull")) {
|
|
3219
3219
|
hasRecognized = true;
|
|
3220
3220
|
if (filter.isNull !== true) throw createAggregateError(AGGREGATE_ERROR.FILTER_UNSUPPORTED, `groupBy() field '${fieldName}'.isNull only supports true.`);
|
|
3221
|
-
this._pushGroupByConstraint(constraints, fieldName, [null]);
|
|
3221
|
+
this._pushGroupByConstraint(constraints, fieldName, [null, void 0]);
|
|
3222
3222
|
}
|
|
3223
3223
|
if (Object.hasOwn(filter, "gt") || Object.hasOwn(filter, "gte") || Object.hasOwn(filter, "lt") || Object.hasOwn(filter, "lte")) throw createAggregateError(AGGREGATE_ERROR.FILTER_UNSUPPORTED, `groupBy() requires finite eq/in/isNull constraints for 'by' field '${fieldName}'. Range operators are unsupported for group keys.`);
|
|
3224
3224
|
const unsupportedKeys = Object.keys(filter).filter((key) => ![
|
|
@@ -3267,24 +3267,60 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3267
3267
|
}
|
|
3268
3268
|
return output;
|
|
3269
3269
|
}
|
|
3270
|
+
/**
|
|
3271
|
+
* One group per distinct value, where `null` and absent count as the same
|
|
3272
|
+
* value. They occupy different aggregate buckets, so the emitted group key
|
|
3273
|
+
* and the filter that reads it diverge: the key reports `null` while the
|
|
3274
|
+
* filter keeps `isNull` so the aggregate compiler reads both buckets and
|
|
3275
|
+
* combines their metrics into a single row.
|
|
3276
|
+
*/
|
|
3277
|
+
_buildGroupBySlots(values) {
|
|
3278
|
+
const nullishValues = values.filter((value) => value === null || value === void 0);
|
|
3279
|
+
const slots = [];
|
|
3280
|
+
let mergedNullish = false;
|
|
3281
|
+
for (const value of values) {
|
|
3282
|
+
if (value !== null && value !== void 0) {
|
|
3283
|
+
slots.push({
|
|
3284
|
+
key: value,
|
|
3285
|
+
filter: value,
|
|
3286
|
+
probeCount: 1
|
|
3287
|
+
});
|
|
3288
|
+
continue;
|
|
3289
|
+
}
|
|
3290
|
+
if (mergedNullish) continue;
|
|
3291
|
+
mergedNullish = true;
|
|
3292
|
+
slots.push({
|
|
3293
|
+
key: null,
|
|
3294
|
+
filter: nullishValues.length > 1 ? { isNull: true } : value,
|
|
3295
|
+
probeCount: nullishValues.length
|
|
3296
|
+
});
|
|
3297
|
+
}
|
|
3298
|
+
return slots;
|
|
3299
|
+
}
|
|
3270
3300
|
_buildGroupByCandidates(byFields, byFieldValues) {
|
|
3271
3301
|
if (byFields.length === 0) return [];
|
|
3272
3302
|
const output = [];
|
|
3273
|
-
const
|
|
3274
|
-
const
|
|
3303
|
+
const key = {};
|
|
3304
|
+
const where = {};
|
|
3305
|
+
const build = (index, probeCount) => {
|
|
3275
3306
|
if (index >= byFields.length) {
|
|
3276
|
-
output.push({
|
|
3307
|
+
output.push({
|
|
3308
|
+
key: { ...key },
|
|
3309
|
+
probeCount,
|
|
3310
|
+
where: { ...where }
|
|
3311
|
+
});
|
|
3277
3312
|
return;
|
|
3278
3313
|
}
|
|
3279
3314
|
const field = byFields[index];
|
|
3280
|
-
const
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
build(index + 1);
|
|
3315
|
+
for (const slot of this._buildGroupBySlots(byFieldValues[field] ?? [])) {
|
|
3316
|
+
key[field] = slot.key;
|
|
3317
|
+
where[field] = slot.filter;
|
|
3318
|
+
build(index + 1, probeCount * slot.probeCount);
|
|
3284
3319
|
}
|
|
3285
|
-
delete
|
|
3320
|
+
delete key[field];
|
|
3321
|
+
delete where[field];
|
|
3286
3322
|
};
|
|
3287
|
-
build(0);
|
|
3323
|
+
build(0, 1);
|
|
3288
3324
|
return output;
|
|
3289
3325
|
}
|
|
3290
3326
|
_coerceGroupByByFields(by) {
|
|
@@ -3631,9 +3667,11 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3631
3667
|
const orderSpecs = this._coerceGroupByOrderSpecs(config.orderBy, by, aggregate);
|
|
3632
3668
|
const window = this._coerceGroupByWindowConfig(config, orderSpecs);
|
|
3633
3669
|
const maxKeys = this._getAggregateCartesianMaxKeys();
|
|
3634
|
-
|
|
3670
|
+
let candidateProbeCount = 0;
|
|
3671
|
+
for (const candidate of candidates) candidateProbeCount += candidate.probeCount;
|
|
3672
|
+
if (candidateProbeCount > maxKeys) throw createAggregateError(AGGREGATE_ERROR.ARGS_UNSUPPORTED, `groupBy() expands to ${candidateProbeCount} aggregate key probes, exceeding aggregateCartesianMaxKeys (${maxKeys}). Reduce IN/isNull fan-out or increase defineSchema(..., { defaults: { aggregateCartesianMaxKeys } }).`);
|
|
3635
3673
|
const metricReads = (aggregate.count === true ? 1 : aggregate.count ? (aggregate.count.all ? 1 : 0) + aggregate.count.fields.length : 0) + aggregate.sumFields.length + aggregate.avgFields.length + aggregate.minFields.length + aggregate.maxFields.length;
|
|
3636
|
-
const estimatedWork =
|
|
3674
|
+
const estimatedWork = candidateProbeCount * Math.max(1, metricReads);
|
|
3637
3675
|
const workBudget = this._getAggregateWorkBudget();
|
|
3638
3676
|
if (estimatedWork > workBudget) throw createAggregateError(AGGREGATE_ERROR.ARGS_UNSUPPORTED, `groupBy() estimated work is ${estimatedWork} units, exceeding aggregateWorkBudget (${workBudget}). Reduce group fan-out or increase defineSchema(..., { defaults: { aggregateWorkBudget } }).`);
|
|
3639
3677
|
return {
|
|
@@ -3667,13 +3705,13 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3667
3705
|
const metricConfig = this._buildAggregateMetricConfig(normalized.aggregate);
|
|
3668
3706
|
const byOutputKeys = new Set(normalized.by.map((entry) => entry.raw));
|
|
3669
3707
|
let rows = await this._mapWithConcurrency(normalized.candidates, async (candidate) => {
|
|
3670
|
-
const groupWhere = this._isEmptyWhere(normalized.aggregate.where) ? candidate : { AND: [normalized.aggregate.where, candidate] };
|
|
3708
|
+
const groupWhere = this._isEmptyWhere(normalized.aggregate.where) ? candidate.where : { AND: [normalized.aggregate.where, candidate.where] };
|
|
3671
3709
|
const aggregateRow = await this._executeAggregate({
|
|
3672
3710
|
...metricConfig,
|
|
3673
3711
|
where: groupWhere
|
|
3674
3712
|
});
|
|
3675
3713
|
return {
|
|
3676
|
-
...Object.fromEntries(normalized.by.map((entry) => [entry.raw, this._coerceAggregateReturnValue(entry.field, candidate[entry.field])])),
|
|
3714
|
+
...Object.fromEntries(normalized.by.map((entry) => [entry.raw, this._coerceAggregateReturnValue(entry.field, candidate.key[entry.field])])),
|
|
3677
3715
|
...aggregateRow
|
|
3678
3716
|
};
|
|
3679
3717
|
});
|
|
@@ -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-DtDfpdcH.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-Bke7ULoY.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-DtDfpdcH.js";
|
|
2
2
|
import * as convex_values0 from "convex/values";
|
|
3
3
|
import { GenericId, Validator, Value } from "convex/values";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchedulableFunctionReference, Scheduler, SchemaDefinition, internalActionGeneric, internalMutationGeneric } from "convex/server";
|
|
@@ -102,25 +102,20 @@ declare const migrationStorageTables: {
|
|
|
102
102
|
fieldName: "status";
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
|
-
|
|
105
|
+
migrationId: ConvexTextBuilderInitial<""> & {
|
|
106
106
|
_: {
|
|
107
|
-
|
|
107
|
+
notNull: true;
|
|
108
108
|
};
|
|
109
109
|
} & {
|
|
110
|
-
_: {
|
|
111
|
-
fieldName: "cursor";
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
direction: ConvexTextBuilderInitial<""> & {
|
|
115
110
|
_: {
|
|
116
111
|
tableName: "migration_state";
|
|
117
112
|
};
|
|
118
113
|
} & {
|
|
119
114
|
_: {
|
|
120
|
-
fieldName: "
|
|
115
|
+
fieldName: "migrationId";
|
|
121
116
|
};
|
|
122
117
|
};
|
|
123
|
-
|
|
118
|
+
checksum: ConvexTextBuilderInitial<""> & {
|
|
124
119
|
_: {
|
|
125
120
|
notNull: true;
|
|
126
121
|
};
|
|
@@ -130,10 +125,10 @@ declare const migrationStorageTables: {
|
|
|
130
125
|
};
|
|
131
126
|
} & {
|
|
132
127
|
_: {
|
|
133
|
-
fieldName: "
|
|
128
|
+
fieldName: "checksum";
|
|
134
129
|
};
|
|
135
130
|
};
|
|
136
|
-
|
|
131
|
+
applied: ConvexBooleanBuilderInitial<""> & {
|
|
137
132
|
_: {
|
|
138
133
|
notNull: true;
|
|
139
134
|
};
|
|
@@ -143,29 +138,34 @@ declare const migrationStorageTables: {
|
|
|
143
138
|
};
|
|
144
139
|
} & {
|
|
145
140
|
_: {
|
|
146
|
-
fieldName: "
|
|
141
|
+
fieldName: "applied";
|
|
147
142
|
};
|
|
148
143
|
};
|
|
149
|
-
|
|
144
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
150
145
|
_: {
|
|
151
|
-
|
|
146
|
+
tableName: "migration_state";
|
|
152
147
|
};
|
|
153
148
|
} & {
|
|
149
|
+
_: {
|
|
150
|
+
fieldName: "direction";
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
154
154
|
_: {
|
|
155
155
|
tableName: "migration_state";
|
|
156
156
|
};
|
|
157
157
|
} & {
|
|
158
158
|
_: {
|
|
159
|
-
fieldName: "
|
|
159
|
+
fieldName: "runId";
|
|
160
160
|
};
|
|
161
161
|
};
|
|
162
|
-
|
|
162
|
+
cursor: ConvexTextBuilderInitial<""> & {
|
|
163
163
|
_: {
|
|
164
164
|
tableName: "migration_state";
|
|
165
165
|
};
|
|
166
166
|
} & {
|
|
167
167
|
_: {
|
|
168
|
-
fieldName: "
|
|
168
|
+
fieldName: "cursor";
|
|
169
169
|
};
|
|
170
170
|
};
|
|
171
171
|
processed: ConvexNumberBuilderInitial<""> & {
|
|
@@ -1021,7 +1021,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1021
1021
|
fieldName: "updatedAt";
|
|
1022
1022
|
};
|
|
1023
1023
|
};
|
|
1024
|
-
|
|
1024
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
1025
1025
|
_: {
|
|
1026
1026
|
notNull: true;
|
|
1027
1027
|
};
|
|
@@ -1031,10 +1031,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1031
1031
|
};
|
|
1032
1032
|
} & {
|
|
1033
1033
|
_: {
|
|
1034
|
-
fieldName: "
|
|
1034
|
+
fieldName: "count";
|
|
1035
1035
|
};
|
|
1036
1036
|
};
|
|
1037
|
-
|
|
1037
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
1038
1038
|
_: {
|
|
1039
1039
|
notNull: true;
|
|
1040
1040
|
};
|
|
@@ -1044,10 +1044,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1044
1044
|
};
|
|
1045
1045
|
} & {
|
|
1046
1046
|
_: {
|
|
1047
|
-
fieldName: "
|
|
1047
|
+
fieldName: "indexName";
|
|
1048
1048
|
};
|
|
1049
1049
|
};
|
|
1050
|
-
|
|
1050
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
1051
1051
|
_: {
|
|
1052
1052
|
notNull: true;
|
|
1053
1053
|
};
|
|
@@ -1057,7 +1057,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1057
1057
|
};
|
|
1058
1058
|
} & {
|
|
1059
1059
|
_: {
|
|
1060
|
-
fieldName: "
|
|
1060
|
+
fieldName: "tableKey";
|
|
1061
1061
|
};
|
|
1062
1062
|
};
|
|
1063
1063
|
keyHash: ConvexTextBuilderInitial<""> & {
|
|
@@ -1133,7 +1133,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1133
1133
|
readonly aggregate_member: ConvexTableWithColumns<{
|
|
1134
1134
|
name: "aggregate_member";
|
|
1135
1135
|
columns: {
|
|
1136
|
-
|
|
1136
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1137
1137
|
_: {
|
|
1138
1138
|
notNull: true;
|
|
1139
1139
|
};
|
|
@@ -1143,10 +1143,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1143
1143
|
};
|
|
1144
1144
|
} & {
|
|
1145
1145
|
_: {
|
|
1146
|
-
fieldName: "
|
|
1146
|
+
fieldName: "updatedAt";
|
|
1147
1147
|
};
|
|
1148
1148
|
};
|
|
1149
|
-
|
|
1149
|
+
kind: ConvexTextBuilderInitial<""> & {
|
|
1150
1150
|
_: {
|
|
1151
1151
|
notNull: true;
|
|
1152
1152
|
};
|
|
@@ -1156,7 +1156,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1156
1156
|
};
|
|
1157
1157
|
} & {
|
|
1158
1158
|
_: {
|
|
1159
|
-
fieldName: "
|
|
1159
|
+
fieldName: "kind";
|
|
1160
1160
|
};
|
|
1161
1161
|
};
|
|
1162
1162
|
indexName: ConvexTextBuilderInitial<""> & {
|
|
@@ -1323,11 +1323,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1323
1323
|
readonly aggregate_extrema: ConvexTableWithColumns<{
|
|
1324
1324
|
name: "aggregate_extrema";
|
|
1325
1325
|
columns: {
|
|
1326
|
-
|
|
1327
|
-
_: {
|
|
1328
|
-
$type: convex_values0.Value;
|
|
1329
|
-
};
|
|
1330
|
-
} & {
|
|
1326
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
1331
1327
|
_: {
|
|
1332
1328
|
notNull: true;
|
|
1333
1329
|
};
|
|
@@ -1337,10 +1333,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1337
1333
|
};
|
|
1338
1334
|
} & {
|
|
1339
1335
|
_: {
|
|
1340
|
-
fieldName: "
|
|
1336
|
+
fieldName: "updatedAt";
|
|
1341
1337
|
};
|
|
1342
1338
|
};
|
|
1343
|
-
|
|
1339
|
+
value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
|
|
1340
|
+
_: {
|
|
1341
|
+
$type: convex_values0.Value;
|
|
1342
|
+
};
|
|
1343
|
+
} & {
|
|
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: "value";
|
|
1354
1354
|
};
|
|
1355
1355
|
};
|
|
1356
|
-
|
|
1356
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
1357
1357
|
_: {
|
|
1358
1358
|
notNull: true;
|
|
1359
1359
|
};
|
|
@@ -1363,10 +1363,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1363
1363
|
};
|
|
1364
1364
|
} & {
|
|
1365
1365
|
_: {
|
|
1366
|
-
fieldName: "
|
|
1366
|
+
fieldName: "count";
|
|
1367
1367
|
};
|
|
1368
1368
|
};
|
|
1369
|
-
|
|
1369
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
1370
1370
|
_: {
|
|
1371
1371
|
notNull: true;
|
|
1372
1372
|
};
|
|
@@ -1376,10 +1376,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1376
1376
|
};
|
|
1377
1377
|
} & {
|
|
1378
1378
|
_: {
|
|
1379
|
-
fieldName: "
|
|
1379
|
+
fieldName: "indexName";
|
|
1380
1380
|
};
|
|
1381
1381
|
};
|
|
1382
|
-
|
|
1382
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
1383
1383
|
_: {
|
|
1384
1384
|
notNull: true;
|
|
1385
1385
|
};
|
|
@@ -1389,7 +1389,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1389
1389
|
};
|
|
1390
1390
|
} & {
|
|
1391
1391
|
_: {
|
|
1392
|
-
fieldName: "
|
|
1392
|
+
fieldName: "tableKey";
|
|
1393
1393
|
};
|
|
1394
1394
|
};
|
|
1395
1395
|
keyHash: ConvexTextBuilderInitial<""> & {
|
|
@@ -1589,19 +1589,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1589
1589
|
fieldName: "status";
|
|
1590
1590
|
};
|
|
1591
1591
|
};
|
|
1592
|
-
kind: ConvexTextBuilderInitial<""> & {
|
|
1593
|
-
_: {
|
|
1594
|
-
notNull: true;
|
|
1595
|
-
};
|
|
1596
|
-
} & {
|
|
1597
|
-
_: {
|
|
1598
|
-
tableName: "aggregate_state";
|
|
1599
|
-
};
|
|
1600
|
-
} & {
|
|
1601
|
-
_: {
|
|
1602
|
-
fieldName: "kind";
|
|
1603
|
-
};
|
|
1604
|
-
};
|
|
1605
1592
|
cursor: ConvexTextBuilderInitial<""> & {
|
|
1606
1593
|
_: {
|
|
1607
1594
|
tableName: "aggregate_state";
|
|
@@ -1668,6 +1655,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1668
1655
|
fieldName: "lastError";
|
|
1669
1656
|
};
|
|
1670
1657
|
};
|
|
1658
|
+
kind: ConvexTextBuilderInitial<""> & {
|
|
1659
|
+
_: {
|
|
1660
|
+
notNull: true;
|
|
1661
|
+
};
|
|
1662
|
+
} & {
|
|
1663
|
+
_: {
|
|
1664
|
+
tableName: "aggregate_state";
|
|
1665
|
+
};
|
|
1666
|
+
} & {
|
|
1667
|
+
_: {
|
|
1668
|
+
fieldName: "kind";
|
|
1669
|
+
};
|
|
1670
|
+
};
|
|
1671
1671
|
indexName: ConvexTextBuilderInitial<""> & {
|
|
1672
1672
|
_: {
|
|
1673
1673
|
notNull: true;
|
|
@@ -1744,25 +1744,20 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1744
1744
|
fieldName: "status";
|
|
1745
1745
|
};
|
|
1746
1746
|
};
|
|
1747
|
-
|
|
1747
|
+
migrationId: ConvexTextBuilderInitial<""> & {
|
|
1748
1748
|
_: {
|
|
1749
|
-
|
|
1749
|
+
notNull: true;
|
|
1750
1750
|
};
|
|
1751
1751
|
} & {
|
|
1752
|
-
_: {
|
|
1753
|
-
fieldName: "cursor";
|
|
1754
|
-
};
|
|
1755
|
-
};
|
|
1756
|
-
direction: ConvexTextBuilderInitial<""> & {
|
|
1757
1752
|
_: {
|
|
1758
1753
|
tableName: "migration_state";
|
|
1759
1754
|
};
|
|
1760
1755
|
} & {
|
|
1761
1756
|
_: {
|
|
1762
|
-
fieldName: "
|
|
1757
|
+
fieldName: "migrationId";
|
|
1763
1758
|
};
|
|
1764
1759
|
};
|
|
1765
|
-
|
|
1760
|
+
checksum: ConvexTextBuilderInitial<""> & {
|
|
1766
1761
|
_: {
|
|
1767
1762
|
notNull: true;
|
|
1768
1763
|
};
|
|
@@ -1772,10 +1767,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1772
1767
|
};
|
|
1773
1768
|
} & {
|
|
1774
1769
|
_: {
|
|
1775
|
-
fieldName: "
|
|
1770
|
+
fieldName: "checksum";
|
|
1776
1771
|
};
|
|
1777
1772
|
};
|
|
1778
|
-
|
|
1773
|
+
applied: ConvexBooleanBuilderInitial<""> & {
|
|
1779
1774
|
_: {
|
|
1780
1775
|
notNull: true;
|
|
1781
1776
|
};
|
|
@@ -1785,29 +1780,34 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1785
1780
|
};
|
|
1786
1781
|
} & {
|
|
1787
1782
|
_: {
|
|
1788
|
-
fieldName: "
|
|
1783
|
+
fieldName: "applied";
|
|
1789
1784
|
};
|
|
1790
1785
|
};
|
|
1791
|
-
|
|
1786
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
1792
1787
|
_: {
|
|
1793
|
-
|
|
1788
|
+
tableName: "migration_state";
|
|
1794
1789
|
};
|
|
1795
1790
|
} & {
|
|
1791
|
+
_: {
|
|
1792
|
+
fieldName: "direction";
|
|
1793
|
+
};
|
|
1794
|
+
};
|
|
1795
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
1796
1796
|
_: {
|
|
1797
1797
|
tableName: "migration_state";
|
|
1798
1798
|
};
|
|
1799
1799
|
} & {
|
|
1800
1800
|
_: {
|
|
1801
|
-
fieldName: "
|
|
1801
|
+
fieldName: "runId";
|
|
1802
1802
|
};
|
|
1803
1803
|
};
|
|
1804
|
-
|
|
1804
|
+
cursor: ConvexTextBuilderInitial<""> & {
|
|
1805
1805
|
_: {
|
|
1806
1806
|
tableName: "migration_state";
|
|
1807
1807
|
};
|
|
1808
1808
|
} & {
|
|
1809
1809
|
_: {
|
|
1810
|
-
fieldName: "
|
|
1810
|
+
fieldName: "cursor";
|
|
1811
1811
|
};
|
|
1812
1812
|
};
|
|
1813
1813
|
processed: ConvexNumberBuilderInitial<""> & {
|
package/package.json
CHANGED
|
@@ -67,6 +67,8 @@ const total = await ctx.orm.query.todos.count({ where: { projectId } });
|
|
|
67
67
|
Unfiltered `count()` uses native Convex count syscall (no aggregateIndex required).
|
|
68
68
|
Filtered `count()` accepts `eq`, `in`, `isNull`, `gt`, `gte`, `lt`, `lte`, conjunction via `AND`, and bounded finite DNF `OR` when every branch is index-plannable on one `aggregateIndex`. Requires matching `aggregateIndex`.
|
|
69
69
|
|
|
70
|
+
`isNull: true` matches an explicitly-`null` column and an absent column (a nullable column is optional, so a row inserted without it stores it absent). Matching `null` exactly (`{ status: null }` or `{ status: { eq: null } }`) matches only explicitly-`null` rows. `count()`, `aggregate()`, `groupBy()`, and relation `_count` use the same null semantics as `findMany()`.
|
|
71
|
+
|
|
70
72
|
Windowed count: `count({ where, orderBy, skip, take, cursor })` counts rows within a window.
|
|
71
73
|
|
|
72
74
|
- `skip`/`take` for pagination windows, `cursor` for "after this value" counting (requires `orderBy`, single field in v1)
|
|
@@ -102,6 +104,7 @@ Windowed aggregate:
|
|
|
102
104
|
|
|
103
105
|
- `by` is required
|
|
104
106
|
- every `by` field must be constrained in `where` via `eq`/`in`/`isNull`
|
|
107
|
+
- an `isNull`-constrained `by` field emits one group keyed `null`, covering both explicitly-`null` and absent rows
|
|
105
108
|
- `orderBy` supports `by` fields and selected metric fields
|
|
106
109
|
- `skip`/`take`/`cursor` require explicit `orderBy`
|
|
107
110
|
- `having` supports conjunction filters on `by` fields and selected metrics
|