kitcn 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2539,15 +2539,25 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
2539
2539
  * The where-clause compiler is built from declared indexes only, and `_id` is
2540
2540
  * never one of them, so an `id` filter can never be index-selected: it lands
2541
2541
  * in the post-filters and the stream walks the creation-time index until it
2542
- * happens on the row. `db.get()` reads exactly the rows asked for, so the ids
2543
- * are fetched directly and replayed as a creation-time-ordered stream — the
2544
- * order the scan would have produced, so stage order and cursors are the same.
2542
+ * happens on the row. `db.get()` reads exactly the rows asked for.
2543
+ *
2544
+ * Rows come back in the order the ids were given, one read at a time. Missing
2545
+ * or policy-filtered ids still cost a read, but a page does not reread the
2546
+ * complete list. An `orderBy` on creation time is the exception: an id carries
2547
+ * no creation time, so every id must be read before the first row is placed.
2545
2548
  *
2546
2549
  * Returns null when something else already owns the read: a pinned index, an
2547
2550
  * index the compiler did select, a `where(predicate)`, or an `orderBy` that
2548
2551
  * walks a different index.
2549
2552
  */
2550
2553
  private _buildIdLookupStream;
2554
+ /**
2555
+ * The declared index a stream read can walk to emit `field` in order.
2556
+ *
2557
+ * A stream orders by the index it scans, so only an index that leads with
2558
+ * the field produces that order.
2559
+ */
2560
+ private _findStreamOrderIndex;
2551
2561
  private _buildBasePipelineStream;
2552
2562
  /**
2553
2563
  * Stream equivalent of the `db.query(...)` chain, used when a post-fetch
@@ -4367,7 +4377,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4367
4377
  readonly aggregate_state: ConvexTableWithColumns<{
4368
4378
  name: "aggregate_state";
4369
4379
  columns: {
4370
- kind: ConvexTextBuilderInitial<""> & {
4380
+ status: ConvexTextBuilderInitial<""> & {
4371
4381
  _: {
4372
4382
  notNull: true;
4373
4383
  };
@@ -4377,7 +4387,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4377
4387
  };
4378
4388
  } & {
4379
4389
  _: {
4380
- fieldName: "kind";
4390
+ fieldName: "status";
4381
4391
  };
4382
4392
  };
4383
4393
  cursor: ConvexTextBuilderInitial<""> & {
@@ -4389,7 +4399,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4389
4399
  fieldName: "cursor";
4390
4400
  };
4391
4401
  };
4392
- updatedAt: ConvexNumberBuilderInitial<""> & {
4402
+ kind: ConvexTextBuilderInitial<""> & {
4393
4403
  _: {
4394
4404
  notNull: true;
4395
4405
  };
@@ -4399,10 +4409,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4399
4409
  };
4400
4410
  } & {
4401
4411
  _: {
4402
- fieldName: "updatedAt";
4412
+ fieldName: "kind";
4403
4413
  };
4404
4414
  };
4405
- tableKey: ConvexTextBuilderInitial<""> & {
4415
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4406
4416
  _: {
4407
4417
  notNull: true;
4408
4418
  };
@@ -4412,10 +4422,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4412
4422
  };
4413
4423
  } & {
4414
4424
  _: {
4415
- fieldName: "tableKey";
4425
+ fieldName: "updatedAt";
4416
4426
  };
4417
4427
  };
4418
- indexName: ConvexTextBuilderInitial<""> & {
4428
+ tableKey: ConvexTextBuilderInitial<""> & {
4419
4429
  _: {
4420
4430
  notNull: true;
4421
4431
  };
@@ -4425,10 +4435,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4425
4435
  };
4426
4436
  } & {
4427
4437
  _: {
4428
- fieldName: "indexName";
4438
+ fieldName: "tableKey";
4429
4439
  };
4430
4440
  };
4431
- keyDefinitionHash: ConvexTextBuilderInitial<""> & {
4441
+ indexName: ConvexTextBuilderInitial<""> & {
4432
4442
  _: {
4433
4443
  notNull: true;
4434
4444
  };
@@ -4438,10 +4448,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4438
4448
  };
4439
4449
  } & {
4440
4450
  _: {
4441
- fieldName: "keyDefinitionHash";
4451
+ fieldName: "indexName";
4442
4452
  };
4443
4453
  };
4444
- metricDefinitionHash: ConvexTextBuilderInitial<""> & {
4454
+ keyDefinitionHash: ConvexTextBuilderInitial<""> & {
4445
4455
  _: {
4446
4456
  notNull: true;
4447
4457
  };
@@ -4451,10 +4461,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4451
4461
  };
4452
4462
  } & {
4453
4463
  _: {
4454
- fieldName: "metricDefinitionHash";
4464
+ fieldName: "keyDefinitionHash";
4455
4465
  };
4456
4466
  };
4457
- status: ConvexTextBuilderInitial<""> & {
4467
+ metricDefinitionHash: ConvexTextBuilderInitial<""> & {
4458
4468
  _: {
4459
4469
  notNull: true;
4460
4470
  };
@@ -4464,7 +4474,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4464
4474
  };
4465
4475
  } & {
4466
4476
  _: {
4467
- fieldName: "status";
4477
+ fieldName: "metricDefinitionHash";
4468
4478
  };
4469
4479
  };
4470
4480
  processed: ConvexNumberBuilderInitial<""> & {
@@ -4516,43 +4526,44 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4516
4526
  by_creation_time: ["_creationTime"];
4517
4527
  by_kind_table_index: ["kind", "tableKey", "indexName", "_creationTime"];
4518
4528
  by_kind_status: ["kind", "status", "_creationTime"];
4529
+ by_table_status: ["tableKey", "status", "_creationTime"];
4519
4530
  }, {}, {}, {}>;
4520
4531
  }>, SchemaExtension<{
4521
4532
  readonly migration_state: ConvexTableWithColumns<{
4522
4533
  name: "migration_state";
4523
4534
  columns: {
4524
- cursor: ConvexTextBuilderInitial<""> & {
4535
+ status: ConvexTextBuilderInitial<""> & {
4536
+ _: {
4537
+ notNull: true;
4538
+ };
4539
+ } & {
4525
4540
  _: {
4526
4541
  tableName: "migration_state";
4527
4542
  };
4528
4543
  } & {
4529
4544
  _: {
4530
- fieldName: "cursor";
4545
+ fieldName: "status";
4531
4546
  };
4532
4547
  };
4533
- direction: ConvexTextBuilderInitial<""> & {
4548
+ cursor: ConvexTextBuilderInitial<""> & {
4534
4549
  _: {
4535
4550
  tableName: "migration_state";
4536
4551
  };
4537
4552
  } & {
4538
4553
  _: {
4539
- fieldName: "direction";
4554
+ fieldName: "cursor";
4540
4555
  };
4541
4556
  };
4542
- updatedAt: ConvexNumberBuilderInitial<""> & {
4543
- _: {
4544
- notNull: true;
4545
- };
4546
- } & {
4557
+ direction: ConvexTextBuilderInitial<""> & {
4547
4558
  _: {
4548
4559
  tableName: "migration_state";
4549
4560
  };
4550
4561
  } & {
4551
4562
  _: {
4552
- fieldName: "updatedAt";
4563
+ fieldName: "direction";
4553
4564
  };
4554
4565
  };
4555
- status: ConvexTextBuilderInitial<""> & {
4566
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4556
4567
  _: {
4557
4568
  notNull: true;
4558
4569
  };
@@ -4562,7 +4573,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4562
4573
  };
4563
4574
  } & {
4564
4575
  _: {
4565
- fieldName: "status";
4576
+ fieldName: "updatedAt";
4566
4577
  };
4567
4578
  };
4568
4579
  processed: ConvexNumberBuilderInitial<""> & {
@@ -4675,7 +4686,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4675
4686
  readonly migration_run: ConvexTableWithColumns<{
4676
4687
  name: "migration_run";
4677
4688
  columns: {
4678
- direction: ConvexTextBuilderInitial<""> & {
4689
+ status: ConvexTextBuilderInitial<""> & {
4679
4690
  _: {
4680
4691
  notNull: true;
4681
4692
  };
@@ -4685,10 +4696,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4685
4696
  };
4686
4697
  } & {
4687
4698
  _: {
4688
- fieldName: "direction";
4699
+ fieldName: "status";
4689
4700
  };
4690
4701
  };
4691
- updatedAt: ConvexNumberBuilderInitial<""> & {
4702
+ direction: ConvexTextBuilderInitial<""> & {
4692
4703
  _: {
4693
4704
  notNull: true;
4694
4705
  };
@@ -4698,10 +4709,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4698
4709
  };
4699
4710
  } & {
4700
4711
  _: {
4701
- fieldName: "updatedAt";
4712
+ fieldName: "direction";
4702
4713
  };
4703
4714
  };
4704
- status: ConvexTextBuilderInitial<""> & {
4715
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4705
4716
  _: {
4706
4717
  notNull: true;
4707
4718
  };
@@ -4711,7 +4722,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4711
4722
  };
4712
4723
  } & {
4713
4724
  _: {
4714
- fieldName: "status";
4725
+ fieldName: "updatedAt";
4715
4726
  };
4716
4727
  };
4717
4728
  startedAt: ConvexNumberBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -54,7 +54,7 @@ Windowed count: `count({ where, orderBy, skip, take, cursor })` counts rows with
54
54
  | Error | Cause |
55
55
  | -------------------------- | -------------------------------------------- |
56
56
  | `COUNT_NOT_INDEXED` | No `aggregateIndex` matches the filter shape |
57
- | `COUNT_FILTER_UNSUPPORTED` | Uses unsupported operators |
57
+ | `COUNT_FILTER_UNSUPPORTED` | Unsupported operators, or a range count/aggregate over `aggregateWorkBudget` work units |
58
58
  | `COUNT_INDEX_BUILDING` | Index still backfilling |
59
59
  | `COUNT_RLS_UNSUPPORTED` | Called in RLS-restricted context |
60
60
 
@@ -310,6 +310,15 @@ If rank or aggregate state gets out of sync:
310
310
  kitcn aggregate rebuild
311
311
  ```
312
312
 
313
+ Rebuild clears stored state in scheduled batches. Indexes report `CLEARING`
314
+ while draining and `BUILDING` while recomputing; wait for `READY`.
315
+ Writes targeting a declared index in `CLEARING` fail before the document write;
316
+ retry them after the index advances to `BUILDING` or `READY`.
317
+ Automatic pruning follows aggregate lifecycle state, so kickoff reads stay
318
+ bounded as the backing tables grow. For state-less storage, call
319
+ `aggregateBackfill` in `prune` mode with exact `tableName` and `indexName`
320
+ arguments.
321
+
313
322
  ## When to Use
314
323
 
315
324
  | Need | Use |
@@ -721,7 +721,7 @@ const filtered = results.filter((a) => a.publishedAt >= startDate);
721
721
  ### Performance
722
722
 
723
723
  1. **Index first** — constrain leading index fields. Compound indexes follow prefix rules. Put the `orderBy` column right after the constrained prefix so the scan is already sorted and `limit` bounds the read.
724
- 2. **Bound scans** — use `maxScan` for predicate `where` (cursor mode only).
724
+ 2. **Bound scans** — use `maxScan` for predicate `where` (cursor mode only). A `.select()` ID-list query with `orderBy` needs a single field that an index leads with.
725
725
  3. **Limit results** — always use `limit` or cursor pagination.
726
726
  4. **Cursor stability** — keep same `where`/`orderBy` between page requests.
727
727
  5. **`allowFullScan`** — non-cursor only. Cursor mode uses `maxScan` instead.