kitcn 0.26.3 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/dist/aggregate/index.d.ts +2 -2
- package/dist/{capabilities-QNGgWHQd.d.ts → capabilities-CLCYgRdY.d.ts} +2 -1
- package/dist/orm/aggregate-index/index.d.ts +1 -1
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +34 -19
- package/dist/orm/migrations/index.d.ts +2 -2
- package/dist/react/index.js +43 -18
- package/dist/rsc/index.js +7 -2
- package/dist/solid/index.js +43 -18
- package/dist/{where-clause-compiler-DfFcNKtn.d.ts → where-clause-compiler-CErbOMvj.d.ts} +73 -73
- package/package.json +1 -1
- package/skills/kitcn/references/features/aggregates.md +32 -0
- package/skills/kitcn/references/features/orm.md +8 -0
- package/skills/kitcn/references/features/react.md +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# kitcn
|
|
2
2
|
|
|
3
|
+
## 0.27.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#396](https://github.com/udecode/kitcn/pull/396) [`8fca5cc`](https://github.com/udecode/kitcn/commit/8fca5cc53c37bd6f651cfbfbf50b87d5461d0ce5) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
|
|
8
|
+
|
|
9
|
+
- Match every args variant from `crpc.<path>.queryFilter()` when `args` is
|
|
10
|
+
omitted, `null`, or `{}`, in both the React and Solid bindings. The filter
|
|
11
|
+
built a key with an empty args slot, which TanStack's partial matching never
|
|
12
|
+
matched, so `invalidateQueries` silently refreshed nothing and stale data
|
|
13
|
+
stayed on screen. Pass args to narrow the filter; omit them to reach every
|
|
14
|
+
variant. `crpc.http.*.queryFilter()` follows the same rule.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// Before
|
|
18
|
+
crpc.analytics.getReport.queryFilter(); // ['convexQuery', 'analytics:getReport', undefined] — matched nothing
|
|
19
|
+
queryClient.invalidateQueries(crpc.analytics.getReport.queryFilter()); // no-op
|
|
20
|
+
|
|
21
|
+
// After
|
|
22
|
+
crpc.analytics.getReport.queryFilter(); // ['convexQuery', 'analytics:getReport']
|
|
23
|
+
queryClient.invalidateQueries(crpc.analytics.getReport.queryFilter()); // every args variant
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 0.27.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- [#395](https://github.com/udecode/kitcn/pull/395) [`2c9ffd2`](https://github.com/udecode/kitcn/commit/2c9ffd20987e4a94cb5790cbb72e6249f1fdfcf4) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Breaking changes
|
|
31
|
+
|
|
32
|
+
- Nested `with:` now loads every level it is given, up to 10, instead of quietly dropping everything past the third. A config that nests deeper throws `RELATION_DEPTH_EXCEEDED` rather than returning a shorter tree. Deep `with:` configs that used to come back truncated now come back complete — and read the rows that completeness costs.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
// Before: the fourth level was dropped, with no error
|
|
36
|
+
const rows = await ctx.orm.query.comments.findMany({
|
|
37
|
+
limit: 20,
|
|
38
|
+
with: {
|
|
39
|
+
replies: {
|
|
40
|
+
limit: 10,
|
|
41
|
+
with: { replies: { limit: 10, with: { author: true } } },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
rows[0].replies[0].replies[0].author; // undefined
|
|
46
|
+
|
|
47
|
+
// After: loaded, because it was asked for
|
|
48
|
+
rows[0].replies[0].replies[0].author; // { id, name }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Patches
|
|
52
|
+
|
|
53
|
+
- Resolve `with: { _count }` at every level of a nested `with:`, including the deepest one returned. A tree can now report how many children it withheld without a second pass that re-reads every node the caller already holds.
|
|
54
|
+
|
|
3
55
|
## 0.26.3
|
|
4
56
|
|
|
5
57
|
### 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-CLCYgRdY.js";
|
|
2
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-CErbOMvj.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";
|
|
@@ -3131,7 +3131,7 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
|
|
|
3131
3131
|
* @param rows - Array of parent records to load relations for
|
|
3132
3132
|
* @param withConfig - Relation configuration object
|
|
3133
3133
|
* @param depth - Current recursion depth (default 0)
|
|
3134
|
-
* @param maxDepth -
|
|
3134
|
+
* @param maxDepth - Runaway ceiling for self-referential configs (default `MAX_RELATION_DEPTH`)
|
|
3135
3135
|
* @param targetTableEdges - Edge metadata for nested relations (optional, defaults to this.edgeMetadata)
|
|
3136
3136
|
*/
|
|
3137
3137
|
private _loadRelations;
|
|
@@ -3142,6 +3142,7 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
|
|
|
3142
3142
|
*/
|
|
3143
3143
|
private _loadSingleRelation;
|
|
3144
3144
|
private _createRelationCountError;
|
|
3145
|
+
private _createRelationDepthError;
|
|
3145
3146
|
private _remapRelationCountError;
|
|
3146
3147
|
private _coerceRelationCountWhere;
|
|
3147
3148
|
private _getRelationCountParentKey;
|
|
@@ -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-CLCYgRdY.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-CLCYgRdY.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-CErbOMvj.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
|
@@ -1287,6 +1287,16 @@ const RELATION_COUNT_ERROR = {
|
|
|
1287
1287
|
NOT_INDEXED: "RELATION_COUNT_NOT_INDEXED",
|
|
1288
1288
|
FILTER_UNSUPPORTED: "RELATION_COUNT_FILTER_UNSUPPORTED"
|
|
1289
1289
|
};
|
|
1290
|
+
const RELATION_DEPTH_ERROR = "RELATION_DEPTH_EXCEEDED";
|
|
1291
|
+
/**
|
|
1292
|
+
* How many levels of `with` the relation loader will follow. A `with` config is
|
|
1293
|
+
* a finite object the caller wrote, so its own nesting is the real bound; this
|
|
1294
|
+
* ceiling only stops a self-referential config from recursing forever. Reaching
|
|
1295
|
+
* it throws rather than returning a shallower tree than was asked for, because
|
|
1296
|
+
* a page that quietly drops its deepest level is indistinguishable from a page
|
|
1297
|
+
* whose deepest level is genuinely empty.
|
|
1298
|
+
*/
|
|
1299
|
+
const MAX_RELATION_DEPTH = 10;
|
|
1290
1300
|
/**
|
|
1291
1301
|
* Physical-table-name lookup, keyed on schema identity. The schema is a
|
|
1292
1302
|
* module-level immutable, so the index outlives any single request.
|
|
@@ -2425,7 +2435,9 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
2425
2435
|
operation: "select",
|
|
2426
2436
|
rls: this.rls
|
|
2427
2437
|
});
|
|
2428
|
-
if (!withConfig
|
|
2438
|
+
if (!withConfig) return;
|
|
2439
|
+
const relationNames = Object.keys(withConfig).filter((relationName) => relationName !== "_count");
|
|
2440
|
+
if (relationNames.length > 0 && depth >= maxDepth) throw this._createRelationDepthError(tableConfig, relationNames[0], maxDepth);
|
|
2429
2441
|
for (const [relationName, relationConfig] of Object.entries(withConfig)) {
|
|
2430
2442
|
if (relationName === "_count") {
|
|
2431
2443
|
this._assertRelationCountRlsPlan(relationConfig, edges);
|
|
@@ -2481,9 +2493,9 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
2481
2493
|
const extrasConfig = this.config.extras;
|
|
2482
2494
|
const resolvedExtras = typeof extrasConfig === "function" ? extrasConfig(tableColumns) : extrasConfig;
|
|
2483
2495
|
if (polymorphicState) this._assertPolymorphicAliasCollisions(polymorphicState.configs, requestedWith, resolvedExtras);
|
|
2484
|
-
this._assertRlsSelectPlan(effectiveWith, this.tableConfig, this.edgeMetadata, 0,
|
|
2496
|
+
this._assertRlsSelectPlan(effectiveWith, this.tableConfig, this.edgeMetadata, 0, MAX_RELATION_DEPTH);
|
|
2485
2497
|
let rowsWithRelations = rows;
|
|
2486
|
-
if (effectiveWith) rowsWithRelations = await this._loadRelations(rowsWithRelations, effectiveWith, 0,
|
|
2498
|
+
if (effectiveWith) rowsWithRelations = await this._loadRelations(rowsWithRelations, effectiveWith, 0, MAX_RELATION_DEPTH, this.edgeMetadata, this.tableConfig);
|
|
2487
2499
|
if (polymorphicState) this._synthesizePolymorphicRows(rowsWithRelations, polymorphicState.configs);
|
|
2488
2500
|
if (resolvedExtras) rowsWithRelations = this._applyExtras(rowsWithRelations, resolvedExtras, tableColumns, effectiveWith, this.tableConfig.name, this.tableConfig);
|
|
2489
2501
|
return this._selectColumns(rowsWithRelations, this.config.columns, tableColumns, this.tableConfig);
|
|
@@ -3774,8 +3786,8 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3774
3786
|
if (pipeline) throw new Error("pageByKey cannot be combined with pipeline.");
|
|
3775
3787
|
}
|
|
3776
3788
|
const preflightWith = this._resolveWithVariantsState(config.with, this._resolvePolymorphicFinalizeState()).effectiveWith;
|
|
3777
|
-
this._assertRlsSelectPlan(preflightWith, this.tableConfig, this.edgeMetadata, 0,
|
|
3778
|
-
if (whereFilter) this._assertRlsSelectPlan(this._buildFilterWithConfig(whereFilter, this.tableConfig), this.tableConfig, this.edgeMetadata, 0,
|
|
3789
|
+
this._assertRlsSelectPlan(preflightWith, this.tableConfig, this.edgeMetadata, 0, MAX_RELATION_DEPTH);
|
|
3790
|
+
if (whereFilter) this._assertRlsSelectPlan(this._buildFilterWithConfig(whereFilter, this.tableConfig), this.tableConfig, this.edgeMetadata, 0, MAX_RELATION_DEPTH);
|
|
3779
3791
|
const idLookup = this._extractIdOnlyWhere(whereFilter);
|
|
3780
3792
|
if (idLookup && !vectorSearchConfig && !searchConfig && !wherePredicate && !isCursorPaginated && !pipeline && !pageByKey && endCursor === void 0 && configuredIndex === void 0) {
|
|
3781
3793
|
const orderSpecs = this._orderBySpecs(config.orderBy);
|
|
@@ -3809,7 +3821,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3809
3821
|
order: pageByKey.order
|
|
3810
3822
|
});
|
|
3811
3823
|
let rows = await this._applyRlsSelectFilter(page.page, this.tableConfig);
|
|
3812
|
-
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
3824
|
+
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
3813
3825
|
return {
|
|
3814
3826
|
page: await this._finalizeRows(rows),
|
|
3815
3827
|
indexKeys: page.indexKeys,
|
|
@@ -3935,7 +3947,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3935
3947
|
});
|
|
3936
3948
|
let pageRows = paginationResult.page;
|
|
3937
3949
|
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
3938
|
-
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
3950
|
+
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
3939
3951
|
return {
|
|
3940
3952
|
page: await this._finalizeRows(pageRows),
|
|
3941
3953
|
continueCursor: paginationResult.continueCursor,
|
|
@@ -3948,7 +3960,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
3948
3960
|
let rows = limit === void 0 ? await searchQuery.collect() : await searchQuery.take(offset > 0 ? offset + limit : limit);
|
|
3949
3961
|
if (offset > 0) rows = rows.slice(offset);
|
|
3950
3962
|
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
3951
|
-
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
3963
|
+
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
3952
3964
|
const selectedRows = await this._finalizeRows(rows);
|
|
3953
3965
|
return this._returnSelectedRows(selectedRows);
|
|
3954
3966
|
}
|
|
@@ -4028,7 +4040,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4028
4040
|
});
|
|
4029
4041
|
let pageRows = paginationResult.page;
|
|
4030
4042
|
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
4031
|
-
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4043
|
+
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
4032
4044
|
return {
|
|
4033
4045
|
page: await this._finalizeRows(pageRows),
|
|
4034
4046
|
continueCursor: paginationResult.continueCursor,
|
|
@@ -4044,7 +4056,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4044
4056
|
let rows = limit === void 0 || paginateAfterPostFetchSort ? await streamQuery.collect() : await streamQuery.take(offset > 0 ? offset + limit : limit);
|
|
4045
4057
|
if (!paginateAfterPostFetchSort && offset > 0) rows = rows.slice(offset);
|
|
4046
4058
|
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
4047
|
-
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4059
|
+
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
4048
4060
|
if (usePostFetchSort && postFetchOrders.length > 0) rows = rows.sort((a, b) => this._compareByOrderSpecs(a, b, postFetchOrders));
|
|
4049
4061
|
if (paginateAfterPostFetchSort) {
|
|
4050
4062
|
if (offset > 0) rows = rows.slice(offset);
|
|
@@ -4079,7 +4091,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4079
4091
|
let rows = Array.from(new Map(probeRows.flat().map((row) => [String(row._id), row])).values());
|
|
4080
4092
|
if (queryConfig.postFilters.length > 0) rows = rows.filter((row) => queryConfig.postFilters.every((filter) => this._evaluatePostFetchFilter(row, filter)));
|
|
4081
4093
|
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
4082
|
-
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4094
|
+
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
4083
4095
|
if (postFetchOrders.length > 0) rows = rows.sort((a, b) => this._compareByOrderSpecs(a, b, postFetchOrders));
|
|
4084
4096
|
if (probeOffset > 0) rows = rows.slice(probeOffset);
|
|
4085
4097
|
if (probeLimit !== void 0) rows = rows.slice(0, probeLimit);
|
|
@@ -4090,7 +4102,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4090
4102
|
const visibleRows = await this._applyRlsSelectFilter([row], this.tableConfig);
|
|
4091
4103
|
if (visibleRows.length === 0) return false;
|
|
4092
4104
|
if (!whereFilter) return true;
|
|
4093
|
-
return (await this._applyRelationsFilterToRows(visibleRows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4105
|
+
return (await this._applyRelationsFilterToRows(visibleRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with)).length > 0;
|
|
4094
4106
|
};
|
|
4095
4107
|
if (isCursorPaginated) {
|
|
4096
4108
|
if (queryConfig.strategy === "multiProbe") if (maxScan === void 0) {
|
|
@@ -4116,7 +4128,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4116
4128
|
});
|
|
4117
4129
|
let pageRows = paginationResult.page;
|
|
4118
4130
|
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
4119
|
-
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4131
|
+
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
4120
4132
|
return {
|
|
4121
4133
|
page: await this._finalizeRows(pageRows),
|
|
4122
4134
|
continueCursor: paginationResult.continueCursor,
|
|
@@ -4148,7 +4160,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4148
4160
|
});
|
|
4149
4161
|
let pageRows = paginationResult.page;
|
|
4150
4162
|
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
4151
|
-
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4163
|
+
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
4152
4164
|
return {
|
|
4153
4165
|
page: await this._finalizeRows(pageRows),
|
|
4154
4166
|
continueCursor: paginationResult.continueCursor,
|
|
@@ -4203,7 +4215,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4203
4215
|
});
|
|
4204
4216
|
let pageRows = paginationResult.page;
|
|
4205
4217
|
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
4206
|
-
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4218
|
+
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
4207
4219
|
return {
|
|
4208
4220
|
page: await this._finalizeRows(pageRows),
|
|
4209
4221
|
continueCursor: paginationResult.continueCursor,
|
|
@@ -4235,7 +4247,7 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4235
4247
|
if (queryConfig.postFilters.length > 0) rows = rows.filter((row) => queryConfig.postFilters.every((filter) => this._evaluatePostFetchFilter(row, filter)));
|
|
4236
4248
|
if (!residualLimitStream) {
|
|
4237
4249
|
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
4238
|
-
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0,
|
|
4250
|
+
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, MAX_RELATION_DEPTH, this.config.with);
|
|
4239
4251
|
}
|
|
4240
4252
|
if (sizeAfterPostFilter) {
|
|
4241
4253
|
if (offset > 0) rows = rows.slice(offset);
|
|
@@ -4420,14 +4432,14 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4420
4432
|
* @param rows - Array of parent records to load relations for
|
|
4421
4433
|
* @param withConfig - Relation configuration object
|
|
4422
4434
|
* @param depth - Current recursion depth (default 0)
|
|
4423
|
-
* @param maxDepth -
|
|
4435
|
+
* @param maxDepth - Runaway ceiling for self-referential configs (default `MAX_RELATION_DEPTH`)
|
|
4424
4436
|
* @param targetTableEdges - Edge metadata for nested relations (optional, defaults to this.edgeMetadata)
|
|
4425
4437
|
*/
|
|
4426
|
-
async _loadRelations(rows, withConfig, depth = 0, maxDepth =
|
|
4438
|
+
async _loadRelations(rows, withConfig, depth = 0, maxDepth = MAX_RELATION_DEPTH, targetTableEdges = this.edgeMetadata, tableConfig = this.tableConfig) {
|
|
4427
4439
|
if (!withConfig || rows.length === 0) return rows;
|
|
4428
|
-
if (depth >= maxDepth) return rows;
|
|
4429
4440
|
const relationCountConfig = withConfig._count;
|
|
4430
4441
|
const relationEntries = Object.entries(withConfig).filter(([relationName]) => relationName !== "_count");
|
|
4442
|
+
if (relationEntries.length > 0 && depth >= maxDepth) throw this._createRelationDepthError(tableConfig, relationEntries[0][0], maxDepth);
|
|
4431
4443
|
await Promise.all(relationEntries.map(([relationName, relationConfig]) => this._loadSingleRelation(rows, relationName, relationConfig, depth, maxDepth, targetTableEdges, tableConfig)));
|
|
4432
4444
|
if (relationCountConfig !== void 0) await this._loadRelationCounts(rows, relationCountConfig, targetTableEdges, tableConfig);
|
|
4433
4445
|
return rows;
|
|
@@ -4446,6 +4458,9 @@ var GelRelationalQuery = class GelRelationalQuery extends QueryPromise {
|
|
|
4446
4458
|
_createRelationCountError(code, message) {
|
|
4447
4459
|
return /* @__PURE__ */ new Error(`${code}: ${message}`);
|
|
4448
4460
|
}
|
|
4461
|
+
_createRelationDepthError(tableConfig, relationName, maxDepth) {
|
|
4462
|
+
return /* @__PURE__ */ new Error(`${RELATION_DEPTH_ERROR}: '${tableConfig.name}.${relationName}' nests \`with\` more than ${maxDepth} levels deep. Trim the nesting, or check whether the config object references itself.`);
|
|
4463
|
+
}
|
|
4449
4464
|
_remapRelationCountError(error, relationPath) {
|
|
4450
4465
|
const message = error instanceof Error ? error.message : String(error);
|
|
4451
4466
|
if (message.startsWith(`${COUNT_ERROR.NOT_INDEXED}:`)) return this._createRelationCountError(RELATION_COUNT_ERROR.NOT_INDEXED, `${relationPath} ${message.slice(`${COUNT_ERROR.NOT_INDEXED}: `.length)}`);
|
|
@@ -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-CLCYgRdY.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-CErbOMvj.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 };
|
package/dist/react/index.js
CHANGED
|
@@ -499,6 +499,38 @@ const getTransformer = (transformer) => {
|
|
|
499
499
|
*/
|
|
500
500
|
const encodeWire = (value, transformer) => getTransformer(transformer).input.serialize(value);
|
|
501
501
|
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/internal/query-filter.ts
|
|
504
|
+
/**
|
|
505
|
+
* Whether a `queryFilter` call actually narrowed by args.
|
|
506
|
+
*
|
|
507
|
+
* Nullish args and `{}` all mean "match every args variant". They have to
|
|
508
|
+
* collapse to a shorter prefix key rather than sit in the args slot, because
|
|
509
|
+
* TanStack matches filters with `partialMatchKey`, which walks
|
|
510
|
+
* `Object.keys(filterKey)` — an args slot holding `undefined` or `null` is
|
|
511
|
+
* compared against the real args and fails on every entry that carries any,
|
|
512
|
+
* so the filter silently matches nothing.
|
|
513
|
+
*/
|
|
514
|
+
function hasQueryFilterArgs(args) {
|
|
515
|
+
if (args == null) return false;
|
|
516
|
+
if (typeof args === "object") return Object.keys(args).length > 0;
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Build the key for a Convex `queryFilter`.
|
|
521
|
+
*
|
|
522
|
+
* With args, this is the exact 3-element key and TanStack partial-matches the
|
|
523
|
+
* args object. Without args, it stops before the args slot so the filter
|
|
524
|
+
* matches every variant of the function.
|
|
525
|
+
*/
|
|
526
|
+
function buildConvexFilterKey(prefix, funcName, args) {
|
|
527
|
+
return hasQueryFilterArgs(args) ? [
|
|
528
|
+
prefix,
|
|
529
|
+
funcName,
|
|
530
|
+
args
|
|
531
|
+
] : [prefix, funcName];
|
|
532
|
+
}
|
|
533
|
+
|
|
502
534
|
//#endregion
|
|
503
535
|
//#region src/react/http-proxy.ts
|
|
504
536
|
/**
|
|
@@ -579,10 +611,9 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
579
611
|
}
|
|
580
612
|
if (prop === "queryKey") return (args) => buildHttpQueryKey(routeKey, args);
|
|
581
613
|
if (prop === "queryFilter") return (args, filters) => {
|
|
582
|
-
const hasArgs = args !== void 0 && !(typeof args === "object" && args !== null && Object.keys(args).length === 0);
|
|
583
614
|
return {
|
|
584
615
|
...filters,
|
|
585
|
-
queryKey:
|
|
616
|
+
queryKey: hasQueryFilterArgs(args) ? buildHttpQueryKey(routeKey, args) : buildHttpQueryPrefixKey(routeKey)
|
|
586
617
|
};
|
|
587
618
|
};
|
|
588
619
|
if (prop === "mutationOptions") {
|
|
@@ -813,16 +844,21 @@ function resolveEnabled(allowed, enabled) {
|
|
|
813
844
|
/**
|
|
814
845
|
* Check if query key is for a Convex query function.
|
|
815
846
|
* Format: ['convexQuery', 'namespace:functionName', { args }]
|
|
847
|
+
*
|
|
848
|
+
* Requires the args slot: a 2-element key is a `queryFilter` prefix, never a
|
|
849
|
+
* cache key, and hashing one would serialize `undefined` args and throw.
|
|
816
850
|
*/
|
|
817
851
|
function isConvexQuery(queryKey) {
|
|
818
|
-
return queryKey.length >=
|
|
852
|
+
return queryKey.length >= 3 && queryKey[0] === "convexQuery";
|
|
819
853
|
}
|
|
820
854
|
/**
|
|
821
855
|
* Check if query key is for a Convex action function.
|
|
822
856
|
* Format: ['convexAction', 'namespace:functionName', { args }]
|
|
857
|
+
*
|
|
858
|
+
* Requires the args slot, for the same reason as {@link isConvexQuery}.
|
|
823
859
|
*/
|
|
824
|
-
function isConvexAction
|
|
825
|
-
return queryKey.length >=
|
|
860
|
+
function isConvexAction(queryKey) {
|
|
861
|
+
return queryKey.length >= 3 && queryKey[0] === "convexAction";
|
|
826
862
|
}
|
|
827
863
|
/**
|
|
828
864
|
* Serialize args the same way they go over the wire, so non-native Convex
|
|
@@ -856,7 +892,7 @@ function hashConvexAction(queryKey) {
|
|
|
856
892
|
function createHashFn(fallback = hashKey) {
|
|
857
893
|
return (queryKey) => {
|
|
858
894
|
if (isConvexQuery(queryKey)) return hashConvexQuery(queryKey);
|
|
859
|
-
if (isConvexAction
|
|
895
|
+
if (isConvexAction(queryKey)) return hashConvexAction(queryKey);
|
|
860
896
|
return fallback(queryKey);
|
|
861
897
|
};
|
|
862
898
|
}
|
|
@@ -1254,11 +1290,7 @@ function createRecursiveProxy(api, path, meta, transformer) {
|
|
|
1254
1290
|
const prefix = getQueryKeyPrefix(path, meta);
|
|
1255
1291
|
return {
|
|
1256
1292
|
...filters,
|
|
1257
|
-
queryKey:
|
|
1258
|
-
prefix,
|
|
1259
|
-
funcName,
|
|
1260
|
-
args
|
|
1261
|
-
]
|
|
1293
|
+
queryKey: buildConvexFilterKey(prefix, funcName, args)
|
|
1262
1294
|
};
|
|
1263
1295
|
};
|
|
1264
1296
|
if (prop === "infiniteQueryOptions") return (args = {}, opts = {}) => {
|
|
@@ -1906,13 +1938,6 @@ function isConvexSkipped(queryKey) {
|
|
|
1906
1938
|
return queryKey.length >= 2 && ["convexQuery", "convexAction"].includes(queryKey[0]) && queryKey[2] === "skip";
|
|
1907
1939
|
}
|
|
1908
1940
|
/**
|
|
1909
|
-
* Check if query key is for a Convex action function.
|
|
1910
|
-
* Format: ['convexAction', 'namespace:functionName', { args }]
|
|
1911
|
-
*/
|
|
1912
|
-
function isConvexAction(queryKey) {
|
|
1913
|
-
return queryKey.length >= 2 && queryKey[0] === "convexAction";
|
|
1914
|
-
}
|
|
1915
|
-
/**
|
|
1916
1941
|
* Write a subscription value into an already-resolved Query.
|
|
1917
1942
|
*
|
|
1918
1943
|
* Going through the Query skips the query-key re-hash that the key-based
|
package/dist/rsc/index.js
CHANGED
|
@@ -116,16 +116,21 @@ function createServerCRPCProxy(options) {
|
|
|
116
116
|
/**
|
|
117
117
|
* Check if query key is for a Convex query function.
|
|
118
118
|
* Format: ['convexQuery', 'namespace:functionName', { args }]
|
|
119
|
+
*
|
|
120
|
+
* Requires the args slot: a 2-element key is a `queryFilter` prefix, never a
|
|
121
|
+
* cache key, and hashing one would serialize `undefined` args and throw.
|
|
119
122
|
*/
|
|
120
123
|
function isConvexQuery(queryKey) {
|
|
121
|
-
return queryKey.length >=
|
|
124
|
+
return queryKey.length >= 3 && queryKey[0] === "convexQuery";
|
|
122
125
|
}
|
|
123
126
|
/**
|
|
124
127
|
* Check if query key is for a Convex action function.
|
|
125
128
|
* Format: ['convexAction', 'namespace:functionName', { args }]
|
|
129
|
+
*
|
|
130
|
+
* Requires the args slot, for the same reason as {@link isConvexQuery}.
|
|
126
131
|
*/
|
|
127
132
|
function isConvexAction(queryKey) {
|
|
128
|
-
return queryKey.length >=
|
|
133
|
+
return queryKey.length >= 3 && queryKey[0] === "convexAction";
|
|
129
134
|
}
|
|
130
135
|
/**
|
|
131
136
|
* Serialize args the same way they go over the wire, so non-native Convex
|
package/dist/solid/index.js
CHANGED
|
@@ -800,6 +800,38 @@ const getTransformer = (transformer) => {
|
|
|
800
800
|
*/
|
|
801
801
|
const encodeWire = (value, transformer) => getTransformer(transformer).input.serialize(value);
|
|
802
802
|
|
|
803
|
+
//#endregion
|
|
804
|
+
//#region src/internal/query-filter.ts
|
|
805
|
+
/**
|
|
806
|
+
* Whether a `queryFilter` call actually narrowed by args.
|
|
807
|
+
*
|
|
808
|
+
* Nullish args and `{}` all mean "match every args variant". They have to
|
|
809
|
+
* collapse to a shorter prefix key rather than sit in the args slot, because
|
|
810
|
+
* TanStack matches filters with `partialMatchKey`, which walks
|
|
811
|
+
* `Object.keys(filterKey)` — an args slot holding `undefined` or `null` is
|
|
812
|
+
* compared against the real args and fails on every entry that carries any,
|
|
813
|
+
* so the filter silently matches nothing.
|
|
814
|
+
*/
|
|
815
|
+
function hasQueryFilterArgs(args) {
|
|
816
|
+
if (args == null) return false;
|
|
817
|
+
if (typeof args === "object") return Object.keys(args).length > 0;
|
|
818
|
+
return true;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Build the key for a Convex `queryFilter`.
|
|
822
|
+
*
|
|
823
|
+
* With args, this is the exact 3-element key and TanStack partial-matches the
|
|
824
|
+
* args object. Without args, it stops before the args slot so the filter
|
|
825
|
+
* matches every variant of the function.
|
|
826
|
+
*/
|
|
827
|
+
function buildConvexFilterKey(prefix, funcName, args) {
|
|
828
|
+
return hasQueryFilterArgs(args) ? [
|
|
829
|
+
prefix,
|
|
830
|
+
funcName,
|
|
831
|
+
args
|
|
832
|
+
] : [prefix, funcName];
|
|
833
|
+
}
|
|
834
|
+
|
|
803
835
|
//#endregion
|
|
804
836
|
//#region src/solid/http-proxy.ts
|
|
805
837
|
/**
|
|
@@ -880,10 +912,9 @@ function createRecursiveHttpProxy(opts, path = []) {
|
|
|
880
912
|
}
|
|
881
913
|
if (prop === "queryKey") return (args) => buildHttpQueryKey(routeKey, args);
|
|
882
914
|
if (prop === "queryFilter") return (args, filters) => {
|
|
883
|
-
const hasArgs = args !== void 0 && !(typeof args === "object" && args !== null && Object.keys(args).length === 0);
|
|
884
915
|
return {
|
|
885
916
|
...filters,
|
|
886
|
-
queryKey:
|
|
917
|
+
queryKey: hasQueryFilterArgs(args) ? buildHttpQueryKey(routeKey, args) : buildHttpQueryPrefixKey(routeKey)
|
|
887
918
|
};
|
|
888
919
|
};
|
|
889
920
|
if (prop === "mutationOptions") {
|
|
@@ -1493,11 +1524,7 @@ function createRecursiveProxy(api, path, meta, transformer) {
|
|
|
1493
1524
|
const prefix = getQueryKeyPrefix(path, meta);
|
|
1494
1525
|
return {
|
|
1495
1526
|
...filters,
|
|
1496
|
-
queryKey:
|
|
1497
|
-
prefix,
|
|
1498
|
-
funcName,
|
|
1499
|
-
args
|
|
1500
|
-
]
|
|
1527
|
+
queryKey: buildConvexFilterKey(prefix, funcName, args)
|
|
1501
1528
|
};
|
|
1502
1529
|
};
|
|
1503
1530
|
if (prop === "infiniteQueryOptions") return (args = {}, opts = {}) => {
|
|
@@ -1996,16 +2023,21 @@ async function clearAuthBoundQueries(cache, isAuthBound) {
|
|
|
1996
2023
|
/**
|
|
1997
2024
|
* Check if query key is for a Convex query function.
|
|
1998
2025
|
* Format: ['convexQuery', 'namespace:functionName', { args }]
|
|
2026
|
+
*
|
|
2027
|
+
* Requires the args slot: a 2-element key is a `queryFilter` prefix, never a
|
|
2028
|
+
* cache key, and hashing one would serialize `undefined` args and throw.
|
|
1999
2029
|
*/
|
|
2000
2030
|
function isConvexQuery(queryKey) {
|
|
2001
|
-
return queryKey.length >=
|
|
2031
|
+
return queryKey.length >= 3 && queryKey[0] === "convexQuery";
|
|
2002
2032
|
}
|
|
2003
2033
|
/**
|
|
2004
2034
|
* Check if query key is for a Convex action function.
|
|
2005
2035
|
* Format: ['convexAction', 'namespace:functionName', { args }]
|
|
2036
|
+
*
|
|
2037
|
+
* Requires the args slot, for the same reason as {@link isConvexQuery}.
|
|
2006
2038
|
*/
|
|
2007
|
-
function isConvexAction
|
|
2008
|
-
return queryKey.length >=
|
|
2039
|
+
function isConvexAction(queryKey) {
|
|
2040
|
+
return queryKey.length >= 3 && queryKey[0] === "convexAction";
|
|
2009
2041
|
}
|
|
2010
2042
|
/**
|
|
2011
2043
|
* Serialize args the same way they go over the wire, so non-native Convex
|
|
@@ -2039,7 +2071,7 @@ function hashConvexAction(queryKey) {
|
|
|
2039
2071
|
function createHashFn(fallback = hashKey) {
|
|
2040
2072
|
return (queryKey) => {
|
|
2041
2073
|
if (isConvexQuery(queryKey)) return hashConvexQuery(queryKey);
|
|
2042
|
-
if (isConvexAction
|
|
2074
|
+
if (isConvexAction(queryKey)) return hashConvexAction(queryKey);
|
|
2043
2075
|
return fallback(queryKey);
|
|
2044
2076
|
};
|
|
2045
2077
|
}
|
|
@@ -2123,13 +2155,6 @@ function isConvexSkipped(queryKey) {
|
|
|
2123
2155
|
return queryKey.length >= 2 && ["convexQuery", "convexAction"].includes(queryKey[0]) && queryKey[2] === "skip";
|
|
2124
2156
|
}
|
|
2125
2157
|
/**
|
|
2126
|
-
* Check if query key is for a Convex action function.
|
|
2127
|
-
* Format: ['convexAction', 'namespace:functionName', { args }]
|
|
2128
|
-
*/
|
|
2129
|
-
function isConvexAction(queryKey) {
|
|
2130
|
-
return queryKey.length >= 2 && queryKey[0] === "convexAction";
|
|
2131
|
-
}
|
|
2132
|
-
/**
|
|
2133
2158
|
* Bridges TanStack Query with Convex real-time subscriptions (SolidJS).
|
|
2134
2159
|
*
|
|
2135
2160
|
* Uses `ConvexClient.onUpdate()` instead of `ConvexReactClient.watchQuery()`.
|
|
@@ -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-CLCYgRdY.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,19 +120,6 @@ 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
|
-
};
|
|
136
123
|
migrationId: ConvexTextBuilderInitial<""> & {
|
|
137
124
|
_: {
|
|
138
125
|
notNull: true;
|
|
@@ -203,6 +190,19 @@ declare const migrationStorageTables: {
|
|
|
203
190
|
fieldName: "startedAt";
|
|
204
191
|
};
|
|
205
192
|
};
|
|
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
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
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: "runId";
|
|
283
283
|
};
|
|
284
284
|
};
|
|
285
|
-
|
|
285
|
+
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
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: "startedAt";
|
|
296
296
|
};
|
|
297
297
|
};
|
|
298
|
-
|
|
298
|
+
updatedAt: 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: "updatedAt";
|
|
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
|
+
updatedAt: 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: "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
|
+
tableKey: 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: "tableKey";
|
|
1048
1048
|
};
|
|
1049
1049
|
};
|
|
1050
|
-
|
|
1050
|
+
indexName: 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: "indexName";
|
|
1061
1061
|
};
|
|
1062
1062
|
};
|
|
1063
1063
|
keyHash: ConvexTextBuilderInitial<""> & {
|
|
@@ -1159,7 +1159,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1159
1159
|
fieldName: "updatedAt";
|
|
1160
1160
|
};
|
|
1161
1161
|
};
|
|
1162
|
-
|
|
1162
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
1163
1163
|
_: {
|
|
1164
1164
|
notNull: true;
|
|
1165
1165
|
};
|
|
@@ -1169,10 +1169,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1169
1169
|
};
|
|
1170
1170
|
} & {
|
|
1171
1171
|
_: {
|
|
1172
|
-
fieldName: "
|
|
1172
|
+
fieldName: "tableKey";
|
|
1173
1173
|
};
|
|
1174
1174
|
};
|
|
1175
|
-
|
|
1175
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
1176
1176
|
_: {
|
|
1177
1177
|
notNull: true;
|
|
1178
1178
|
};
|
|
@@ -1182,7 +1182,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1182
1182
|
};
|
|
1183
1183
|
} & {
|
|
1184
1184
|
_: {
|
|
1185
|
-
fieldName: "
|
|
1185
|
+
fieldName: "indexName";
|
|
1186
1186
|
};
|
|
1187
1187
|
};
|
|
1188
1188
|
keyHash: ConvexTextBuilderInitial<""> & {
|
|
@@ -1340,7 +1340,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1340
1340
|
fieldName: "value";
|
|
1341
1341
|
};
|
|
1342
1342
|
};
|
|
1343
|
-
|
|
1343
|
+
updatedAt: 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: "updatedAt";
|
|
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
|
+
tableKey: 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: "tableKey";
|
|
1380
1380
|
};
|
|
1381
1381
|
};
|
|
1382
|
-
|
|
1382
|
+
indexName: 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: "indexName";
|
|
1393
1393
|
};
|
|
1394
1394
|
};
|
|
1395
1395
|
keyHash: ConvexTextBuilderInitial<""> & {
|
|
@@ -1611,7 +1611,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1611
1611
|
fieldName: "cursor";
|
|
1612
1612
|
};
|
|
1613
1613
|
};
|
|
1614
|
-
|
|
1614
|
+
processed: 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: "processed";
|
|
1625
1625
|
};
|
|
1626
1626
|
};
|
|
1627
|
-
|
|
1627
|
+
startedAt: 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: "startedAt";
|
|
1638
1638
|
};
|
|
1639
1639
|
};
|
|
1640
|
-
|
|
1640
|
+
updatedAt: 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: "updatedAt";
|
|
1651
1651
|
};
|
|
1652
1652
|
};
|
|
1653
1653
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
|
@@ -1668,7 +1668,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1668
1668
|
fieldName: "lastError";
|
|
1669
1669
|
};
|
|
1670
1670
|
};
|
|
1671
|
-
|
|
1671
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
1672
1672
|
_: {
|
|
1673
1673
|
notNull: true;
|
|
1674
1674
|
};
|
|
@@ -1678,10 +1678,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1678
1678
|
};
|
|
1679
1679
|
} & {
|
|
1680
1680
|
_: {
|
|
1681
|
-
fieldName: "
|
|
1681
|
+
fieldName: "tableKey";
|
|
1682
1682
|
};
|
|
1683
1683
|
};
|
|
1684
|
-
|
|
1684
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
1685
1685
|
_: {
|
|
1686
1686
|
notNull: true;
|
|
1687
1687
|
};
|
|
@@ -1691,10 +1691,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1691
1691
|
};
|
|
1692
1692
|
} & {
|
|
1693
1693
|
_: {
|
|
1694
|
-
fieldName: "
|
|
1694
|
+
fieldName: "indexName";
|
|
1695
1695
|
};
|
|
1696
1696
|
};
|
|
1697
|
-
|
|
1697
|
+
keyDefinitionHash: ConvexTextBuilderInitial<""> & {
|
|
1698
1698
|
_: {
|
|
1699
1699
|
notNull: true;
|
|
1700
1700
|
};
|
|
@@ -1704,10 +1704,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1704
1704
|
};
|
|
1705
1705
|
} & {
|
|
1706
1706
|
_: {
|
|
1707
|
-
fieldName: "
|
|
1707
|
+
fieldName: "keyDefinitionHash";
|
|
1708
1708
|
};
|
|
1709
1709
|
};
|
|
1710
|
-
|
|
1710
|
+
metricDefinitionHash: ConvexTextBuilderInitial<""> & {
|
|
1711
1711
|
_: {
|
|
1712
1712
|
notNull: true;
|
|
1713
1713
|
};
|
|
@@ -1717,7 +1717,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1717
1717
|
};
|
|
1718
1718
|
} & {
|
|
1719
1719
|
_: {
|
|
1720
|
-
fieldName: "
|
|
1720
|
+
fieldName: "metricDefinitionHash";
|
|
1721
1721
|
};
|
|
1722
1722
|
};
|
|
1723
1723
|
};
|
|
@@ -1762,19 +1762,6 @@ 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
|
-
};
|
|
1778
1765
|
migrationId: ConvexTextBuilderInitial<""> & {
|
|
1779
1766
|
_: {
|
|
1780
1767
|
notNull: true;
|
|
@@ -1845,6 +1832,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1845
1832
|
fieldName: "startedAt";
|
|
1846
1833
|
};
|
|
1847
1834
|
};
|
|
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
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
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: "runId";
|
|
1925
1925
|
};
|
|
1926
1926
|
};
|
|
1927
|
-
|
|
1927
|
+
startedAt: ConvexNumberBuilderInitial<""> & {
|
|
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: "startedAt";
|
|
1938
1938
|
};
|
|
1939
1939
|
};
|
|
1940
|
-
|
|
1940
|
+
updatedAt: 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: "updatedAt";
|
|
1951
1951
|
};
|
|
1952
1952
|
};
|
|
1953
1953
|
completedAt: ConvexNumberBuilderInitial<""> & {
|
package/package.json
CHANGED
|
@@ -211,6 +211,38 @@ const users = await ctx.orm.query.users.findMany({
|
|
|
211
211
|
|
|
212
212
|
Works on `findMany`, `findFirst`, `findFirstOrThrow`. Access via `row._count?.relation ?? 0`.
|
|
213
213
|
|
|
214
|
+
`_count` reads an aggregate index rather than the rows, so it resolves at every level of a nested `with:`, including the deepest level returned. Ask for it there instead of re-reading the returned tree to attach counts — that second pass costs one read per node the caller already holds:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
// ❌ BAD: second pass over nodes already in hand
|
|
218
|
+
const roots = await ctx.orm.query.comments.findMany({
|
|
219
|
+
where: { parentId: { isNull: true } },
|
|
220
|
+
limit: 20,
|
|
221
|
+
with: { replies: { limit: 10 } },
|
|
222
|
+
});
|
|
223
|
+
const ids = collectIds(roots);
|
|
224
|
+
const counts = await ctx.orm.query.comments.findMany({
|
|
225
|
+
where: { id: { in: ids } },
|
|
226
|
+
limit: ids.length,
|
|
227
|
+
columns: { id: true },
|
|
228
|
+
with: { _count: { replies: true } },
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// ✅ GOOD: counted inline, at every level
|
|
232
|
+
const roots = await ctx.orm.query.comments.findMany({
|
|
233
|
+
where: { parentId: { isNull: true } },
|
|
234
|
+
limit: 20,
|
|
235
|
+
with: {
|
|
236
|
+
_count: { replies: true },
|
|
237
|
+
replies: {
|
|
238
|
+
limit: 10,
|
|
239
|
+
with: { _count: { replies: true } },
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
// roots[0].replies[0]._count?.replies => replies not in this page
|
|
244
|
+
```
|
|
245
|
+
|
|
214
246
|
### Mutation `returning({ _count })`
|
|
215
247
|
|
|
216
248
|
```ts
|
|
@@ -261,6 +261,14 @@ orders by creation time, so `with: { posts: { limit: 5, orderBy: { createdAt:
|
|
|
261
261
|
parent's whole child partition and sorts in memory — put the sort column in the
|
|
262
262
|
relation index (`index('by_user_rank').on(t.userId, t.rank)`) to stay bounded.
|
|
263
263
|
|
|
264
|
+
### Nested `with` depth
|
|
265
|
+
|
|
266
|
+
Nested `with:` loads every level it is given, up to 10. A tree that still has
|
|
267
|
+
rows to expand past that throws `RELATION_DEPTH_EXCEEDED` rather than coming back
|
|
268
|
+
shorter than requested — which is how a `with` object that references itself
|
|
269
|
+
surfaces. Fan-out per level is bounded by that level's `limit`, not by the depth
|
|
270
|
+
ceiling.
|
|
271
|
+
|
|
264
272
|
## Schema Definition
|
|
265
273
|
|
|
266
274
|
```ts
|
|
@@ -235,11 +235,20 @@ useQuery(crpc.user.get.queryOptions(userId ? { id: userId } : skipToken));
|
|
|
235
235
|
|
|
236
236
|
### Query Keys & Filters
|
|
237
237
|
|
|
238
|
+
`queryKey(args)` is the exact cache key — use it for `getQueryData`/`setQueryData`.
|
|
239
|
+
`queryFilter(args?)` matches on prefix — use it for `invalidateQueries`/`cancelQueries`/`removeQueries`.
|
|
240
|
+
|
|
238
241
|
```ts
|
|
239
242
|
const queryKey = crpc.user.list.queryKey({}); // ['convexQuery', 'user:list', {}]
|
|
240
243
|
const data = queryClient.getQueryData(queryKey);
|
|
241
244
|
|
|
242
|
-
|
|
245
|
+
// Omit args to match every args variant: ['convexQuery', 'user:list']
|
|
246
|
+
queryClient.invalidateQueries(crpc.user.list.queryFilter());
|
|
247
|
+
|
|
248
|
+
// Partial args match every query whose args contain them
|
|
249
|
+
queryClient.invalidateQueries(crpc.user.list.queryFilter({ status: 'active' }));
|
|
250
|
+
|
|
251
|
+
const filter = crpc.user.list.queryFilter({ status: 'active' }, { predicate: (q) => q.state.dataUpdatedAt > Date.now() - 60000 });
|
|
243
252
|
queryClient.invalidateQueries(filter);
|
|
244
253
|
```
|
|
245
254
|
|