kitcn 0.27.2 → 0.27.4

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 CHANGED
@@ -1,5 +1,50 @@
1
1
  # kitcn
2
2
 
3
+ ## 0.27.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#400](https://github.com/udecode/kitcn/pull/400) [`9963d33`](https://github.com/udecode/kitcn/commit/9963d33048ec532f0a2d9a06bb618486856178b1) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
8
+
9
+ - Speed up `kitcn analyze` by measuring every selected entry in one bundler pass
10
+ instead of one pass per entry: 4.3 s → 0.8 s of bundling on the 24-entry example
11
+ app, with byte-identical `OutMB`. Each entry is still sized as its own
12
+ independently tree-shaken isolate, so the ranking is unchanged.
13
+ - Report the hotspot `DepMB` and `Files` columns for the files that carry weight in
14
+ each entry's isolate. They previously counted every file the bundler parsed,
15
+ including files tree-shaking dropped entirely, which disagreed with the `--details`
16
+ package and input tables directly beneath them. Expect both columns to read lower
17
+ than before for the same code; `OutMB` and `LocMB` are unaffected.
18
+ - Fix `kitcn analyze` crashing with a bundler stack trace when a Convex entry fails
19
+ to build. It now lists the entry under `Failed entries:`, keeps reporting every
20
+ entry that did build, and still exits `1`. This needs esbuild `0.27.7`, which is
21
+ now the minimum.
22
+ - Warn which entries had their `./schema` imports externalized after a build error,
23
+ instead of leaving the default mode silent about approximate dependency sizes. The
24
+ approximation is applied per entry, so one unbuildable schema import no longer
25
+ shrinks the numbers for unrelated functions.
26
+ - Open the interactive analyzer's package and input panes without a second bundle, so
27
+ moving the selection no longer pauses to rebuild.
28
+ - Document the hotspot ranking columns, in `--help` and in the CLI reference, along
29
+ with the `--top-inputs` / `--top-packages` flags.
30
+
31
+ ## 0.27.3
32
+
33
+ ### Patch Changes
34
+
35
+ - [#398](https://github.com/udecode/kitcn/pull/398) [`71158af`](https://github.com/udecode/kitcn/commit/71158af254e97942d382c9b87f736466fb2fbdbd) Thanks [@MikeyZhang75](https://github.com/MikeyZhang75)! - ## Patches
36
+
37
+ - Fix `aggregateBackfill` cutting an in-progress clear short when the same run
38
+ also sees a changed metric definition. A `CLEARING` index now finishes draining
39
+ before it moves to `BUILDING`, which is what `resume` already documented, and
40
+ it applies to `aggregateIndex` and `rankIndex` alike. Previously a metric or
41
+ sum change landing while `kitcn aggregate rebuild` was still draining could
42
+ abandon the rebuild halfway and still report `READY`, leaving `count()`,
43
+ `aggregate()` and `rank()` answering from state no document backs.
44
+ - Refuse to advance an index out of `CLEARING` while any of its stored state
45
+ survives. The backfill now fails loudly instead of rebuilding on top of a
46
+ half-drained index and serving numbers that are quietly wrong.
47
+
3
48
  ## 0.27.2
4
49
 
5
50
  ### Patch Changes
@@ -1,5 +1,5 @@
1
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-ChMQ575O.js";
2
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-DAPEBp1y.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-BEc4d98x.js";
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 };
@@ -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-BEc4d98x.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-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", "field" | "direction">;
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.field" | "sortBy.direction">;
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;
package/dist/cli.mjs CHANGED
@@ -454,6 +454,13 @@ Modes:
454
454
  (default) Hotspot analysis (per-function isolate ranking)
455
455
  --deploy Deploy analysis (single isolate bundle, Convex-like)
456
456
 
457
+ Hotspot columns (all describe what the entry actually bundles):
458
+ OutMB Bundled size of the isolate this entry deploys into
459
+ DepMB Source size of the dependency files in that isolate
460
+ LocMB Source size of your own Convex files in that isolate
461
+ Files Files contributing bytes to that isolate
462
+ Fns Convex handlers exported by the entry
463
+
457
464
  Flags:
458
465
  --details Show extra per-entry/package details
459
466
  --input Include top internal inputs in detail output
@@ -522,13 +529,46 @@ const packageFromInputPath = (inputPath) => {
522
529
  }
523
530
  return "(other)";
524
531
  };
525
- const buildHotspotEntry = (entryPoint, externalizeSchema) => loadEsbuild().build({
532
+ /** Matches the `out: 'e<index>'` names `createHotspotBuildOptions` assigns. */
533
+ const HOTSPOT_ENTRY_OUTPUT_REGEX = /^out\/e(\d+)\.[^/]+$/;
534
+ const isLocalInputPath = (inputPath) => inputPath.startsWith("convex/") || inputPath.startsWith("example/convex/") || inputPath.includes("/example/convex/");
535
+ /**
536
+ * Hotspot ranks each Convex function by the isolate it deploys into, so every
537
+ * entry needs its own fully tree-shaken closure.
538
+ *
539
+ * esbuild parses each input once per build no matter how many entry points it
540
+ * receives, and with splitting OFF every entry output still carries its own
541
+ * independently tree-shaken closure. Passing the whole entry set to one build
542
+ * therefore keeps per-entry byte counts identical to building each entry alone
543
+ * while reading the shared import graph once.
544
+ *
545
+ * Do not turn on `splitting` here. Shared chunks retain code a lone entry would
546
+ * have dropped, which inflates exactly the number this mode ranks by (measured
547
+ * up to +70% on `example`) and turns dynamic imports into extra outputs that
548
+ * carry an `entryPoint`. `--deploy` already owns the split-bundle view.
549
+ *
550
+ * Each entry is given an explicit output name so its result can be found by
551
+ * position instead of by path. esbuild resolves a symlinked source file to its
552
+ * real path before reporting `output.entryPoint`, so matching that field back
553
+ * against the selected entry would silently lose any entry reached through a
554
+ * symlink. Explicit names also make `foo.ts` and `foo.js` in one directory
555
+ * unable to collide on a single output path.
556
+ *
557
+ * `attributeHotspotBuild` must be given the same `entryPoints` array, since the
558
+ * output name is the entry's index in it.
559
+ */
560
+ const createHotspotBuildOptions = (entryPoints, projectRoot, externalizeSchema) => ({
561
+ absWorkingDir: projectRoot,
526
562
  bundle: true,
527
- entryPoints: [entryPoint],
563
+ entryPoints: entryPoints.map((entryPoint, index) => ({
564
+ in: entryPoint,
565
+ out: `e${index}`
566
+ })),
528
567
  external: ["convex", "convex/*"],
529
568
  format: "esm",
530
569
  logLevel: "silent",
531
570
  metafile: true,
571
+ outdir: "out",
532
572
  platform: "browser",
533
573
  target: ["esnext"],
534
574
  conditions: ["convex", "module"],
@@ -539,42 +579,67 @@ const buildHotspotEntry = (entryPoint, externalizeSchema) => loadEsbuild().build
539
579
  write: false,
540
580
  plugins: externalizeSchema ? [schemaExternalFallbackPlugin] : []
541
581
  });
542
- const analyzeHotspotEntry = async (entryPoint, projectRoot, includeDeepData) => {
543
- let result;
544
- let schemaExternalized = false;
582
+ /**
583
+ * `allowSchemaFallback` is off for the shared pass on purpose. Externalizing
584
+ * `./schema` removes real weight from every entry that imports it, not just the
585
+ * one that failed: forcing it across `example` moved 25 of 26 rows, one by
586
+ * -98%. Letting the shared pass fail and rebuilding per entry instead keeps the
587
+ * approximation on the entries that actually need it.
588
+ */
589
+ const buildHotspotBundle = async (entryPoints, projectRoot, allowSchemaFallback) => {
545
590
  try {
546
- result = await buildHotspotEntry(entryPoint, false);
591
+ return {
592
+ result: await loadEsbuild().build(createHotspotBuildOptions(entryPoints, projectRoot, false)),
593
+ schemaExternalized: false
594
+ };
547
595
  } catch (error) {
548
- if (!shouldRetryWithSchemaExternalized(error)) throw error;
549
- result = await buildHotspotEntry(entryPoint, true);
550
- schemaExternalized = true;
596
+ if (!(allowSchemaFallback && shouldRetryWithSchemaExternalized(error))) throw error;
597
+ return {
598
+ result: await loadEsbuild().build(createHotspotBuildOptions(entryPoints, projectRoot, true)),
599
+ schemaExternalized: true
600
+ };
601
+ }
602
+ };
603
+ /**
604
+ * Row metrics describe what actually weighs something in the entry's isolate.
605
+ *
606
+ * They count the inputs that emit bytes into that entry's output, which is the
607
+ * same set the `--details` package and input tables below them already report.
608
+ * The build-wide `meta.inputs` cannot answer this: it lists every file esbuild
609
+ * parsed, including ones tree-shaking dropped entirely (534 of 1545 on
610
+ * `example`), and a shared bundle makes it the union across entries rather than
611
+ * one entry's graph. It stays the lookup table for *source* bytes, so `LocMB`
612
+ * and `DepMB` keep measuring source weight rather than post-minify weight.
613
+ */
614
+ const buildHotspotRow = (params) => {
615
+ const { entryPoint, projectRoot, inputs, output, includeDeepData, schemaExternalized } = params;
616
+ const outputInputEntries = Object.entries(output.inputs ?? {});
617
+ let inputCount = 0;
618
+ let totalInputBytes = 0;
619
+ let localInputBytes = 0;
620
+ for (const [inputPath, value] of outputInputEntries) {
621
+ if ((value.bytesInOutput ?? 0) <= 0) continue;
622
+ inputCount += 1;
623
+ const sourceBytes = inputs[inputPath]?.bytes ?? 0;
624
+ totalInputBytes += sourceBytes;
625
+ if (isLocalInputPath(inputPath)) localInputBytes += sourceBytes;
551
626
  }
552
- const meta = result.metafile;
553
- if (!meta) throw new Error(`No metafile generated for ${entryPoint}`);
554
- const output = Object.values(meta.outputs).at(0);
555
- if (!output) throw new Error(`No output generated for ${entryPoint}`);
556
- const inputEntries = Object.entries(meta.inputs);
557
- const totalInputBytes = inputEntries.reduce((sum, [, value]) => sum + (value.bytes ?? 0), 0);
558
- const isLocalInput = (inputPath) => inputPath.startsWith("convex/") || inputPath.startsWith("example/convex/") || inputPath.includes("/example/convex/");
559
- const localInputBytes = inputEntries.filter(([inputPath]) => isLocalInput(inputPath)).reduce((sum, [, value]) => sum + (value.bytes ?? 0), 0);
560
627
  const row = {
561
628
  entry: path.relative(projectRoot, entryPoint),
562
- inputCount: inputEntries.length,
629
+ inputCount,
563
630
  localInputBytes,
564
631
  dependencyInputBytes: Math.max(0, totalInputBytes - localInputBytes),
565
- totalInputBytes,
566
632
  outputBytes: output.bytes,
567
633
  schemaExternalized
568
634
  };
569
635
  if (!includeDeepData) return row;
570
- const bytesByInput = new Map(inputEntries.map(([inputPath, value]) => [inputPath, value.bytes ?? 0]));
571
- const outputInputs = Object.entries(output.inputs ?? {}).map(([inputPath, value]) => ({
636
+ const outputInputs = outputInputEntries.map(([inputPath, value]) => ({
572
637
  path: inputPath,
573
638
  bytesInOutput: value.bytesInOutput ?? 0,
574
- sourceBytes: bytesByInput.get(inputPath) ?? 0
639
+ sourceBytes: inputs[inputPath]?.bytes ?? 0
575
640
  })).sort((a, b) => b.bytesInOutput - a.bytesInOutput);
576
- const inputSet = new Set(inputEntries.map(([inputPath]) => inputPath));
577
- const importsByInput = Object.fromEntries(inputEntries.map(([inputPath, value]) => [inputPath, Array.from(new Set((value.imports ?? []).map((entry) => entry.path).filter((importPath) => typeof importPath === "string" && inputSet.has(importPath))))]));
641
+ const inputSet = new Set(outputInputEntries.map(([inputPath]) => inputPath));
642
+ const importsByInput = Object.fromEntries(outputInputEntries.map(([inputPath]) => [inputPath, Array.from(new Set((inputs[inputPath]?.imports ?? []).map((entry) => entry.path).filter((importPath) => typeof importPath === "string" && inputSet.has(importPath))))]));
578
643
  return {
579
644
  ...row,
580
645
  deep: {
@@ -583,6 +648,34 @@ const analyzeHotspotEntry = async (entryPoint, projectRoot, includeDeepData) =>
583
648
  }
584
649
  };
585
650
  };
651
+ /**
652
+ * Pairs each entry with its output through the position `createHotspotBuildOptions`
653
+ * encoded in the output name, so `entryPoints` must be the array that built `meta`.
654
+ */
655
+ const attributeHotspotBuild = (params) => {
656
+ const { entryPoints, projectRoot, meta, includeDeepData, schemaExternalized } = params;
657
+ const inputs = meta.inputs;
658
+ const outputByEntryIndex = /* @__PURE__ */ new Map();
659
+ for (const [outputPath, output] of Object.entries(meta.outputs)) {
660
+ const index = HOTSPOT_ENTRY_OUTPUT_REGEX.exec(outputPath)?.[1];
661
+ if (index === void 0) continue;
662
+ outputByEntryIndex.set(Number(index), output);
663
+ }
664
+ const rowsByEntry = /* @__PURE__ */ new Map();
665
+ for (const [index, entryPoint] of entryPoints.entries()) {
666
+ const output = outputByEntryIndex.get(index);
667
+ if (!output) throw new Error(`esbuild produced no output for ${path.relative(projectRoot, entryPoint)}.`);
668
+ rowsByEntry.set(entryPoint, buildHotspotRow({
669
+ entryPoint,
670
+ includeDeepData,
671
+ inputs,
672
+ output,
673
+ projectRoot,
674
+ schemaExternalized
675
+ }));
676
+ }
677
+ return rowsByEntry;
678
+ };
586
679
  const printHotspotTopInputs = (row, options) => {
587
680
  if (!row.deep) return;
588
681
  const internalInputs = row.deep.outputInputs.filter((input) => input.bytesInOutput > 0 && !isNodeModulesInputPath(input.path));
@@ -866,37 +959,106 @@ const collectAnalyzeEntrySelection = async (roots, options) => {
866
959
  };
867
960
  const MAX_ANALYZE_CONCURRENCY = 8;
868
961
  /**
869
- * esbuild bundles are independent, so the entry sweep runs through a bounded
870
- * pool instead of one build at a time. The cap stays low enough to avoid
871
- * oversubscribing esbuild's worker pool on small machines.
962
+ * Only the per-entry recovery sweep still runs multiple builds, so the cap
963
+ * stays low enough to avoid oversubscribing esbuild's worker pool on small
964
+ * machines.
872
965
  */
873
966
  const resolveAnalyzeConcurrency = (taskCount) => {
874
967
  if (taskCount <= 1) return 1;
875
968
  const cpuCount = os.cpus().length || 1;
876
969
  return Math.max(1, Math.min(MAX_ANALYZE_CONCURRENCY, cpuCount - 1, taskCount));
877
970
  };
878
- const collectHotspotRows = async (roots, options, includeDeepData) => {
879
- const { isolateEntries, generatedEntries, entryPoints, handlerExportsByEntry } = await collectAnalyzeEntrySelection(roots, options);
880
- const rows = await mapWithConcurrency(entryPoints, resolveAnalyzeConcurrency(entryPoints.length), async (entryPoint) => {
971
+ const toErrorMessage = (error) => error instanceof Error ? error.message : String(error);
972
+ const runHotspotBuild = async (entryPoints, projectRoot, includeDeepData, allowSchemaFallback, build) => {
973
+ const { result, schemaExternalized } = await build(entryPoints, projectRoot, allowSchemaFallback);
974
+ const meta = result.metafile;
975
+ if (!meta) throw new Error("esbuild produced no metafile for the hotspot bundle.");
976
+ return attributeHotspotBuild({
977
+ entryPoints,
978
+ includeDeepData,
979
+ meta,
980
+ projectRoot,
981
+ schemaExternalized
982
+ });
983
+ };
984
+ /**
985
+ * Recovery path only. A shared build fails as a unit, so one unbuildable entry
986
+ * would take the whole report down. Rebuilding one entry at a time is the only
987
+ * way to say *which* entry is broken, and it reuses the same build options so
988
+ * surviving rows keep the numbers the shared pass would have produced. It is
989
+ * also where the schema fallback belongs, since here it only degrades the
990
+ * entries that actually need it.
991
+ *
992
+ * Reaching this path needs esbuild >= 0.27.7. Earlier builds threw
993
+ * `SyntaxError: Unexpected end of JSON input` out of esbuild's own stdout
994
+ * handler whenever a `metafile: true` build failed, which is outside any promise
995
+ * this module can catch, so the CLI died before any sweep could report a failed
996
+ * row.
997
+ */
998
+ const sweepHotspotEntriesIndividually = async (entryPoints, projectRoot, includeDeepData, build) => {
999
+ const results = await mapWithConcurrency(entryPoints, resolveAnalyzeConcurrency(entryPoints.length), async (entryPoint) => {
881
1000
  try {
882
1001
  return {
883
- ...await analyzeHotspotEntry(entryPoint, roots.projectRoot, includeDeepData),
884
- handlerExports: handlerExportsByEntry.get(entryPoint) ?? []
1002
+ rowsByEntry: await runHotspotBuild([entryPoint], projectRoot, includeDeepData, true, build),
1003
+ failedRows: []
885
1004
  };
886
1005
  } catch (error) {
887
1006
  return {
888
- entry: path.relative(roots.projectRoot, entryPoint),
889
- error: error instanceof Error ? error.message : String(error)
1007
+ rowsByEntry: /* @__PURE__ */ new Map(),
1008
+ failedRows: [{
1009
+ entry: path.relative(projectRoot, entryPoint),
1010
+ error: toErrorMessage(error)
1011
+ }]
890
1012
  };
891
1013
  }
892
1014
  });
1015
+ const rowsByEntry = /* @__PURE__ */ new Map();
1016
+ const failedRows = [];
1017
+ for (const result of results) {
1018
+ for (const [entryPoint, row] of result.rowsByEntry) rowsByEntry.set(entryPoint, row);
1019
+ failedRows.push(...result.failedRows);
1020
+ }
1021
+ return {
1022
+ rowsByEntry,
1023
+ failedRows
1024
+ };
1025
+ };
1026
+ const sweepHotspotEntries = async (entryPoints, projectRoot, includeDeepData, build = buildHotspotBundle) => {
1027
+ if (entryPoints.length === 0) return {
1028
+ rowsByEntry: /* @__PURE__ */ new Map(),
1029
+ failedRows: [],
1030
+ fallbackReason: null
1031
+ };
1032
+ try {
1033
+ return {
1034
+ rowsByEntry: await runHotspotBuild(entryPoints, projectRoot, includeDeepData, false, build),
1035
+ failedRows: [],
1036
+ fallbackReason: null
1037
+ };
1038
+ } catch (error) {
1039
+ return {
1040
+ ...await sweepHotspotEntriesIndividually(entryPoints, projectRoot, includeDeepData, build),
1041
+ fallbackReason: firstLine(toErrorMessage(error))
1042
+ };
1043
+ }
1044
+ };
1045
+ const collectHotspotRows = async (roots, options, includeDeepData) => {
1046
+ const { isolateEntries, generatedEntries, entryPoints, handlerExportsByEntry } = await collectAnalyzeEntrySelection(roots, options);
1047
+ const { rowsByEntry, failedRows, fallbackReason } = await sweepHotspotEntries(entryPoints, roots.projectRoot, includeDeepData);
893
1048
  return {
894
1049
  isolateEntries,
895
1050
  generatedEntries,
896
1051
  entryPoints,
897
- successRows: rows.filter((row) => !("error" in row)).sort((a, b) => b.outputBytes - a.outputBytes),
898
- failedRows: rows.filter((row) => "error" in row),
899
- handlerExportsByEntry
1052
+ successRows: entryPoints.flatMap((entryPoint) => {
1053
+ const row = rowsByEntry.get(entryPoint);
1054
+ if (!row) return [];
1055
+ return [{
1056
+ ...row,
1057
+ handlerExports: handlerExportsByEntry.get(entryPoint) ?? []
1058
+ }];
1059
+ }).sort((a, b) => b.outputBytes - a.outputBytes),
1060
+ failedRows,
1061
+ fallbackReason
900
1062
  };
901
1063
  };
902
1064
  const buildPackageImportGraphRows = (row, limit = 12) => {
@@ -1021,7 +1183,7 @@ const runHotspotInteractive = async (roots, options) => {
1021
1183
  ...options,
1022
1184
  includeGenerated: state.includeGenerated,
1023
1185
  entryPattern: null
1024
- }, false);
1186
+ }, true);
1025
1187
  let visibleRows = sortHotspotRows(filterHotspotRows(snapshot.successRows, state.filterQuery), state.sortKey);
1026
1188
  let watcher = null;
1027
1189
  let watchTimer = null;
@@ -1029,7 +1191,6 @@ const runHotspotInteractive = async (roots, options) => {
1029
1191
  let refreshQueued = false;
1030
1192
  let shouldQuit = false;
1031
1193
  let listViewportHeight = 10;
1032
- const deepRowCache = /* @__PURE__ */ new Map();
1033
1194
  const getSelectedEntry = () => visibleRows.at(state.selectedIndex)?.entry ?? null;
1034
1195
  const findRowByEntry = (entry) => {
1035
1196
  if (!entry) return null;
@@ -1064,8 +1225,7 @@ const runHotspotInteractive = async (roots, options) => {
1064
1225
  ...options,
1065
1226
  includeGenerated: state.includeGenerated,
1066
1227
  entryPattern: null
1067
- }, false);
1068
- deepRowCache.clear();
1228
+ }, true);
1069
1229
  syncVisibleRows(preferredEntry);
1070
1230
  state = reduceInteractiveState(state, {
1071
1231
  type: "setStatus",
@@ -1147,28 +1307,7 @@ const runHotspotInteractive = async (roots, options) => {
1147
1307
  stdin.setEncoding("utf8");
1148
1308
  }
1149
1309
  };
1150
- const ensureDeepRow = async (entry) => {
1151
- if (deepRowCache.has(entry)) return deepRowCache.get(entry) ?? null;
1152
- const entryPoint = path.join(roots.projectRoot, entry);
1153
- try {
1154
- const analyzed = await analyzeHotspotEntry(entryPoint, roots.projectRoot, true);
1155
- const fallbackHandlers = findRowByEntry(entry)?.handlerExports ?? [];
1156
- const mergedRow = {
1157
- ...analyzed,
1158
- handlerExports: snapshot.handlerExportsByEntry.get(entryPoint) ?? fallbackHandlers
1159
- };
1160
- deepRowCache.set(entry, mergedRow);
1161
- return mergedRow;
1162
- } catch (error) {
1163
- deepRowCache.set(entry, null);
1164
- state = reduceInteractiveState(state, {
1165
- type: "setStatus",
1166
- message: `Detail load failed for ${entry}: ${firstLine(error instanceof Error ? error.message : String(error))}`
1167
- });
1168
- return null;
1169
- }
1170
- };
1171
- const renderInteractive = async () => {
1310
+ const renderInteractive = () => {
1172
1311
  const layout = resolveInteractiveLayout(stdout.columns ?? outputWidth, stdout.rows ?? 30);
1173
1312
  listViewportHeight = layout.listViewportHeight;
1174
1313
  state = reduceInteractiveState(state, {
@@ -1176,8 +1315,7 @@ const runHotspotInteractive = async (roots, options) => {
1176
1315
  topIndex: fitListViewport(visibleRows.length, state.selectedIndex, layout.listViewportHeight, state.topIndex)
1177
1316
  });
1178
1317
  const activeEntry = (visibleRows.at(state.selectedIndex) ?? null)?.entry ?? null;
1179
- let detailRow = findRowByEntry(activeEntry);
1180
- if (!state.showHelp && activeEntry && state.detailPane !== "handlers") detailRow = await ensureDeepRow(activeEntry);
1318
+ const detailRow = findRowByEntry(activeEntry);
1181
1319
  const statusLine = state.statusMessage || "Ready";
1182
1320
  const headerLine = `entries=${visibleRows.length}/${snapshot.successRows.length} sort=${sortLabel(state.sortKey)} filter=${state.filterQuery || "∅"} all=${state.includeGenerated ? "on" : "off"} pane=${state.detailPane} watch=${state.watchEnabled ? "on" : "off"}`;
1183
1321
  const listLines = (() => {
@@ -1231,7 +1369,7 @@ const runHotspotInteractive = async (roots, options) => {
1231
1369
  stdin.setEncoding("utf8");
1232
1370
  try {
1233
1371
  while (!shouldQuit) {
1234
- await renderInteractive();
1372
+ renderInteractive();
1235
1373
  const key = await readKey();
1236
1374
  if (key === "" || key === "q") {
1237
1375
  shouldQuit = true;
@@ -1317,7 +1455,7 @@ const runHotspotInteractive = async (roots, options) => {
1317
1455
  const runHotspotAnalysis = async (roots, options) => {
1318
1456
  if (shouldPromptForHotspotPick(options)) return runHotspotInteractive(roots, options);
1319
1457
  const includeDeepData = options.details;
1320
- const { isolateEntries, generatedEntries, entryPoints, successRows, failedRows } = await collectHotspotRows(roots, options, includeDeepData);
1458
+ const { isolateEntries, generatedEntries, entryPoints, successRows, failedRows, fallbackReason } = await collectHotspotRows(roots, options, includeDeepData);
1321
1459
  if (entryPoints.length === 0) {
1322
1460
  if (options.includeGenerated) console.log("No matching entries found for the provided regex.");
1323
1461
  else console.log("No matching Convex handler entries found (files exporting query/mutation/action, including internal variants).");
@@ -1343,6 +1481,9 @@ const runHotspotAnalysis = async (roots, options) => {
1343
1481
  const actionRows = successRows;
1344
1482
  console.log(bold("Runtime hotspot analysis (least optimized functions)"));
1345
1483
  console.log(`isolateEntries=${isolateEntries.length} handlers=${totalHandlers} extraAll=${generatedEntries.length} selected=${entryPoints.length} ok=${successRows.length} failed=${failedRows.length} avg=${formatBytes(outputAverage)}${largest ? ` largest=${largest.entry} (${formatBytes(largest.outputBytes)})` : ""}`);
1484
+ if (fallbackReason) console.log(dim(`note: the shared bundle failed, so entries were rebuilt one at a time: ${fallbackReason}`));
1485
+ const approximateRows = successRows.filter((row) => row.schemaExternalized);
1486
+ if (approximateRows.length > 0) console.log(colorize(`note: schema imports were externalized after a build error for ${approximateRows.length} ${approximateRows.length === 1 ? "entry" : "entries"}; their dependency sizes are approximate (${approximateRows.map((row) => row.entry).join(", ")}).`, ANSI.yellow));
1346
1487
  console.log("");
1347
1488
  if (actionRows.length > 0) {
1348
1489
  console.log(bold("Agent queue (run top-down):"));
@@ -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,6 +1,6 @@
1
1
  import { t as DirectAggregate } from "../../runtime-CcOvOf4K.js";
2
2
  import { a as Columns } from "../../table-CX2lnX7e.js";
3
- import { Y as normalizeTemporalComparableValue, bt as PUBLIC_CREATED_AT_FIELD, c as AGGREGATE_ERROR, f as createError, i as AGGREGATE_STATE_TABLE, l as COUNT_ERROR, lt as mapWithConcurrency, n as AGGREGATE_EXTREMA_TABLE, o as getAggregateIndexDefinitions, r as AGGREGATE_MEMBER_TABLE, s as getRankIndexDefinitions, t as AGGREGATE_BUCKET_TABLE, xt as usesSystemCreatedAtAlias, yt as INTERNAL_CREATION_TIME_FIELD } from "../../schema-e0wbZ_Ax.js";
3
+ import { Ct as usesSystemCreatedAtAlias, St as PUBLIC_CREATED_AT_FIELD, Z as normalizeTemporalComparableValue, a as AGGREGATE_STATE_TABLE, c as getAggregateIndexDefinitions, d as COUNT_ERROR, dt as mapWithConcurrency, i as AGGREGATE_RANK_TREE_TABLE, l as getRankIndexDefinitions, m as createError, n as AGGREGATE_EXTREMA_TABLE, r as AGGREGATE_MEMBER_TABLE, s as rankAggregateName, t as AGGREGATE_BUCKET_TABLE, u as AGGREGATE_ERROR, xt as INTERNAL_CREATION_TIME_FIELD } from "../../schema-C5WWEqsj.js";
4
4
 
5
5
  //#region src/orm/aggregate-index/runtime.ts
6
6
  const UNDEFINED_SENTINEL = "__kitcnUndefined";
@@ -1256,6 +1256,18 @@ const assertAggregateIndexesWritable = async (db, tableName, metricIndexNames, r
1256
1256
  const indexType = blockingState.kind === AGGREGATE_STATE_KIND_RANK ? "rankIndex" : "aggregateIndex";
1257
1257
  throw createError(blockingState.kind === AGGREGATE_STATE_KIND_RANK ? "RANK_INDEX_BUILDING" : AGGREGATE_ERROR.INDEX_BUILDING, `${indexType} '${tableName}.${blockingState.indexName}' is CLEARING. Retry the write after aggregateBackfill reaches BUILDING or READY.`);
1258
1258
  };
1259
+ /**
1260
+ * Read-only mirror of the emptiness checks the clear chunks drive to
1261
+ * completion. `clearCountIndexChunk` and `clearRankIndexChunk` report `done`
1262
+ * from the same conditions, so this is what "the clear finished" means without
1263
+ * writing anything.
1264
+ */
1265
+ const isIndexStateDrained = async (db, kind, tableName, indexName) => {
1266
+ if (await db.query(AGGREGATE_MEMBER_TABLE).withIndex("by_kind_table_index", (q) => q.eq("kind", kind).eq("tableKey", tableName).eq("indexName", indexName)).first()) return false;
1267
+ if (kind === AGGREGATE_STATE_KIND_RANK) return await db.query(AGGREGATE_RANK_TREE_TABLE).withIndex("by_aggregate_name", (q) => q.eq("aggregateName", rankAggregateName(tableName, indexName))).first() === null;
1268
+ const [bucket, extrema] = await Promise.all([db.query(AGGREGATE_BUCKET_TABLE).withIndex("by_table_index", (q) => q.eq("tableKey", tableName).eq("indexName", indexName)).first(), db.query(AGGREGATE_EXTREMA_TABLE).withIndex("by_table_index", (q) => q.eq("tableKey", tableName).eq("indexName", indexName)).first()]);
1269
+ return bucket === null && extrema === null;
1270
+ };
1259
1271
  const setCountState = async (db, nextState, kind = AGGREGATE_STATE_KIND_METRIC) => {
1260
1272
  const existing = await getCountState(db, nextState.tableName, nextState.indexName, kind);
1261
1273
  const payload = {
@@ -1276,6 +1288,10 @@ const setCountState = async (db, nextState, kind = AGGREGATE_STATE_KIND_METRIC)
1276
1288
  await db.insert(AGGREGATE_STATE_TABLE, payload);
1277
1289
  return;
1278
1290
  }
1291
+ if (existing.status === COUNT_STATUS_CLEARING && payload.status !== COUNT_STATUS_CLEARING && !await isIndexStateDrained(db, kind, nextState.tableName, nextState.indexName)) {
1292
+ const indexType = kind === AGGREGATE_STATE_KIND_RANK ? "rankIndex" : "aggregateIndex";
1293
+ throw new Error(`${indexType} '${nextState.tableName}.${nextState.indexName}' is CLEARING with stored state left; refusing to move it to ${payload.status}. Finish the clear before advancing the index.`);
1294
+ }
1279
1295
  await db.patch(AGGREGATE_STATE_TABLE, existing._id, payload);
1280
1296
  };
1281
1297
  const setCountStateError = async (db, tableName, indexName, error, kind = AGGREGATE_STATE_KIND_METRIC) => {
@@ -1377,7 +1393,6 @@ const RANK_ERROR = {
1377
1393
  RLS_UNSUPPORTED: "RANK_RLS_UNSUPPORTED"
1378
1394
  };
1379
1395
  const createRankError = (code, message) => /* @__PURE__ */ new Error(`${code}: ${message}`);
1380
- const rankAggregateName = (tableName, indexName) => `${tableName}.${indexName}`;
1381
1396
  const rankAggregate = (tableName, indexName) => new DirectAggregate({ name: rankAggregateName(tableName, indexName) });
1382
1397
  const toRankValue = (value) => {
1383
1398
  if (value === null || value === void 0) return null;
@@ -1905,10 +1920,11 @@ function createCountBackfillHandlers(schema, getChunkRef) {
1905
1920
  skippedReady += 1;
1906
1921
  continue;
1907
1922
  }
1923
+ const cleared = existing.status === COUNT_STATUS_CLEARING ? await drainIndexClear(ctx, target.kind, target.tableName, target.indexName, batchSize, clearBudget) : true;
1908
1924
  await setCountState(ctx.db, {
1909
1925
  ...nextStateBase,
1910
1926
  kind: stateKind,
1911
- status: COUNT_STATUS_BUILDING,
1927
+ status: cleared ? COUNT_STATUS_BUILDING : COUNT_STATUS_CLEARING,
1912
1928
  cursor: null,
1913
1929
  processed: 0,
1914
1930
  startedAt: now,
@@ -1,5 +1,5 @@
1
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-ChMQ575O.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-DAPEBp1y.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
@@ -4,7 +4,7 @@ import { a as pretendRequired, i as pretend, n as deprecated } from "../validato
4
4
  import { t as id } from "../id-CuSfWa5q.js";
5
5
  import { A as or, C as matchLikePattern, D as notIlike, E as notBetween, O as notInArray, S as lte, T as not, _ as isFieldReference, a as between, b as like, c as endsWith, d as filterValueInList, f as filterValuesEqual, g as inArray, h as ilike, i as arrayOverlaps, j as startsWith, k as notLike, l as eq, m as gte, n as arrayContained, o as column, p as gt, r as arrayContains, s as contains, t as and, u as fieldRef, v as isNotNull, w as ne, x as lt, y as isNull } from "../filter-expression-Dydt8wS0.js";
6
6
  import { a as indexKeyWithinBounds, c as streamIndexRange, i as getIndexFields, l as isUnsetToken, n as EmptyStream, o as mergedStream, r as QueryStream, s as stream, t as getByIdWithOrmQueryFallback, u as unsetToken } from "../query-context-DOm5Xm3H.js";
7
- import { $ as serializeFilterExpression, A as ensureNonNullValues, B as getMutationExecutionMode, C as deserializeFilterExpression, D as enforcePolymorphicWrite, E as enforceForeignKeys, F as getChecks, G as getUniqueIndexes, H as getTableColumns$2, I as getColumnName$1, J as normalizeDateFieldsForWrite, K as hardDeleteRow, L as getForeignKeys, M as evaluateCheckConstraintTriState, N as evaluateFilter, O as enforceUniqueIndexes, P as extractPrimaryIdLookup, Q as selectReturningRowWithHydration, R as getMutationAsyncDelayMs, S as decodeUndefinedDeep, T as enforceCheckConstraints, U as getTableDeleteConfig, V as getOrmContext, W as getTableName, X as patchReferencingRows, Y as normalizeTemporalComparableValue, Z as resolveOrmRuntimeDefaults, _ as applyIncomingForeignKeyActionsOnUpdate, _t as resolveIndexOrderPushdown, a as aggregateExtension, at as markLifecycleHookedTables, b as collectMutationRowsBounded, bt as PUBLIC_CREATED_AT_FIELD, c as AGGREGATE_ERROR, ct as isConvexEnforceableFilter, d as createCountError, dt as findRelationIndex, et as softDeleteRow, ft as findSearchIndexByName, g as applyIncomingForeignKeyActionsOnDelete, gt as getRankIndexes, h as applyDefaults, ht as getIndexes, it as hasLifecycleHooks, j as ensureNullableColumns, k as ensureDefaultColumns, l as COUNT_ERROR, lt as mapWithConcurrency, m as ensureCountAllowedForRls, mt as getAggregateIndexes, nt as takeRowsWithinByteBudget, o as getAggregateIndexDefinitions, ot as compileConvexFilter, p as ensureAggregateAllowedForRls, pt as findVectorIndexByName, q as hydrateDateFieldsForRead, rt as toConvexFilter, s as getRankIndexDefinitions, st as convexAnd, tt as splitReturningSelection, u as createAggregateError, ut as findIndexForColumns, v as buildForeignKeyGraph, vt as CREATED_AT_MIGRATION_MESSAGE, w as encodeUndefinedDeep, x as collectPrimaryIdLookupRows, xt as usesSystemCreatedAtAlias, y as canUsePrimaryIdLookupCursor, yt as INTERNAL_CREATION_TIME_FIELD, z as getMutationCollectionLimits } from "../schema-e0wbZ_Ax.js";
7
+ import { $ as resolveOrmRuntimeDefaults, A as enforceUniqueIndexes, B as getMutationAsyncDelayMs, C as collectPrimaryIdLookupRows, Ct as usesSystemCreatedAtAlias, D as enforceCheckConstraints, E as encodeUndefinedDeep, F as evaluateFilter, G as getTableDeleteConfig, H as getMutationExecutionMode, I as extractPrimaryIdLookup, J as hardDeleteRow, K as getTableName, L as getChecks, M as ensureNonNullValues, N as ensureNullableColumns, O as enforceForeignKeys, P as evaluateCheckConstraintTriState, Q as patchReferencingRows, R as getColumnName$1, S as collectMutationRowsBounded, St as PUBLIC_CREATED_AT_FIELD, T as deserializeFilterExpression, U as getOrmContext, V as getMutationCollectionLimits, W as getTableColumns$2, X as normalizeDateFieldsForWrite, Y as hydrateDateFieldsForRead, Z as normalizeTemporalComparableValue, _ as applyDefaults, _t as getIndexes, at as toConvexFilter, b as buildForeignKeyGraph, bt as CREATED_AT_MIGRATION_MESSAGE, c as getAggregateIndexDefinitions, ct as compileConvexFilter, d as COUNT_ERROR, dt as mapWithConcurrency, et as selectReturningRowWithHydration, f as createAggregateError, ft as findIndexForColumns, g as ensureCountAllowedForRls, gt as getAggregateIndexes, h as ensureAggregateAllowedForRls, ht as findVectorIndexByName, it as takeRowsWithinByteBudget, j as ensureDefaultColumns, k as enforcePolymorphicWrite, l as getRankIndexDefinitions, lt as convexAnd, mt as findSearchIndexByName, nt as softDeleteRow, o as aggregateExtension, ot as hasLifecycleHooks, p as createCountError, pt as findRelationIndex, q as getUniqueIndexes, rt as splitReturningSelection, st as markLifecycleHookedTables, tt as serializeFilterExpression, u as AGGREGATE_ERROR, ut as isConvexEnforceableFilter, v as applyIncomingForeignKeyActionsOnDelete, vt as getRankIndexes, w as decodeUndefinedDeep, x as canUsePrimaryIdLookupCursor, xt as INTERNAL_CREATION_TIME_FIELD, y as applyIncomingForeignKeyActionsOnUpdate, yt as resolveIndexOrderPushdown, z as getForeignKeys } from "../schema-C5WWEqsj.js";
8
8
  import { t as defineSchemaExtension } from "../extensions-Blzsyekm.js";
9
9
  import { compareValues, v } from "convex/values";
10
10
  import { defineSchema as defineSchema$1, internalActionGeneric, internalMutationGeneric } from "convex/server";
@@ -1,3 +1,3 @@
1
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-ChMQ575O.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-DAPEBp1y.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 };
@@ -1394,6 +1394,12 @@ const AGGREGATE_EXTREMA_TABLE = "aggregate_extrema";
1394
1394
  const AGGREGATE_RANK_TREE_TABLE = "aggregate_rank_tree";
1395
1395
  const AGGREGATE_RANK_NODE_TABLE = "aggregate_rank_node";
1396
1396
  const AGGREGATE_STATE_TABLE = "aggregate_state";
1397
+ /**
1398
+ * Partition key a rank index's btree rows are stored under. Lives next to the
1399
+ * table names because it is how `AGGREGATE_RANK_TREE_TABLE` is addressed, and
1400
+ * both the rank runtime and the state machine have to agree on it.
1401
+ */
1402
+ const rankAggregateName = (tableName, indexName) => `${tableName}.${indexName}`;
1397
1403
  const countBucketTable = convexTable(AGGREGATE_BUCKET_TABLE, {
1398
1404
  tableKey: text().notNull(),
1399
1405
  indexName: text().notNull(),
@@ -1483,4 +1489,4 @@ function aggregateExtension() {
1483
1489
  }
1484
1490
 
1485
1491
  //#endregion
1486
- export { serializeFilterExpression as $, ensureNonNullValues as A, getMutationExecutionMode as B, deserializeFilterExpression as C, enforcePolymorphicWrite as D, enforceForeignKeys as E, getChecks as F, getUniqueIndexes as G, getTableColumns as H, getColumnName as I, normalizeDateFieldsForWrite as J, hardDeleteRow as K, getForeignKeys as L, evaluateCheckConstraintTriState as M, evaluateFilter as N, enforceUniqueIndexes as O, extractPrimaryIdLookup as P, selectReturningRowWithHydration as Q, getMutationAsyncDelayMs as R, decodeUndefinedDeep as S, enforceCheckConstraints as T, getTableDeleteConfig as U, getOrmContext as V, getTableName as W, patchReferencingRows as X, normalizeTemporalComparableValue as Y, resolveOrmRuntimeDefaults as Z, applyIncomingForeignKeyActionsOnUpdate as _, resolveIndexOrderPushdown as _t, aggregateExtension as a, markLifecycleHookedTables as at, collectMutationRowsBounded as b, PUBLIC_CREATED_AT_FIELD as bt, AGGREGATE_ERROR as c, isConvexEnforceableFilter as ct, createCountError as d, findRelationIndex as dt, softDeleteRow as et, createError as f, findSearchIndexByName as ft, applyIncomingForeignKeyActionsOnDelete as g, getRankIndexes as gt, applyDefaults as h, getIndexes as ht, AGGREGATE_STATE_TABLE as i, hasLifecycleHooks as it, ensureNullableColumns as j, ensureDefaultColumns as k, COUNT_ERROR as l, mapWithConcurrency as lt, ensureCountAllowedForRls as m, getAggregateIndexes as mt, AGGREGATE_EXTREMA_TABLE as n, takeRowsWithinByteBudget as nt, getAggregateIndexDefinitions as o, compileConvexFilter as ot, ensureAggregateAllowedForRls as p, findVectorIndexByName as pt, hydrateDateFieldsForRead as q, AGGREGATE_MEMBER_TABLE as r, toConvexFilter as rt, getRankIndexDefinitions as s, convexAnd as st, AGGREGATE_BUCKET_TABLE as t, splitReturningSelection as tt, createAggregateError as u, findIndexForColumns as ut, buildForeignKeyGraph as v, CREATED_AT_MIGRATION_MESSAGE as vt, encodeUndefinedDeep as w, collectPrimaryIdLookupRows as x, usesSystemCreatedAtAlias as xt, canUsePrimaryIdLookupCursor as y, INTERNAL_CREATION_TIME_FIELD as yt, getMutationCollectionLimits as z };
1492
+ export { resolveOrmRuntimeDefaults as $, enforceUniqueIndexes as A, getMutationAsyncDelayMs as B, collectPrimaryIdLookupRows as C, usesSystemCreatedAtAlias as Ct, enforceCheckConstraints as D, encodeUndefinedDeep as E, evaluateFilter as F, getTableDeleteConfig as G, getMutationExecutionMode as H, extractPrimaryIdLookup as I, hardDeleteRow as J, getTableName as K, getChecks as L, ensureNonNullValues as M, ensureNullableColumns as N, enforceForeignKeys as O, evaluateCheckConstraintTriState as P, patchReferencingRows as Q, getColumnName as R, collectMutationRowsBounded as S, PUBLIC_CREATED_AT_FIELD as St, deserializeFilterExpression as T, getOrmContext as U, getMutationCollectionLimits as V, getTableColumns as W, normalizeDateFieldsForWrite as X, hydrateDateFieldsForRead as Y, normalizeTemporalComparableValue as Z, applyDefaults as _, getIndexes as _t, AGGREGATE_STATE_TABLE as a, toConvexFilter as at, buildForeignKeyGraph as b, CREATED_AT_MIGRATION_MESSAGE as bt, getAggregateIndexDefinitions as c, compileConvexFilter as ct, COUNT_ERROR as d, mapWithConcurrency as dt, selectReturningRowWithHydration as et, createAggregateError as f, findIndexForColumns as ft, ensureCountAllowedForRls as g, getAggregateIndexes as gt, ensureAggregateAllowedForRls as h, findVectorIndexByName as ht, AGGREGATE_RANK_TREE_TABLE as i, takeRowsWithinByteBudget as it, ensureDefaultColumns as j, enforcePolymorphicWrite as k, getRankIndexDefinitions as l, convexAnd as lt, createError as m, findSearchIndexByName as mt, AGGREGATE_EXTREMA_TABLE as n, softDeleteRow as nt, aggregateExtension as o, hasLifecycleHooks as ot, createCountError as p, findRelationIndex as pt, getUniqueIndexes as q, AGGREGATE_MEMBER_TABLE as r, splitReturningSelection as rt, rankAggregateName as s, markLifecycleHookedTables as st, AGGREGATE_BUCKET_TABLE as t, serializeFilterExpression as tt, AGGREGATE_ERROR as u, isConvexEnforceableFilter as ut, applyIncomingForeignKeyActionsOnDelete as v, getRankIndexes as vt, decodeUndefinedDeep as w, canUsePrimaryIdLookupCursor as x, INTERNAL_CREATION_TIME_FIELD as xt, applyIncomingForeignKeyActionsOnUpdate as y, resolveIndexOrderPushdown as yt, getForeignKeys as z };
@@ -102,25 +102,20 @@ declare const migrationStorageTables: {
102
102
  fieldName: "status";
103
103
  };
104
104
  };
105
- cursor: ConvexTextBuilderInitial<""> & {
105
+ migrationId: ConvexTextBuilderInitial<""> & {
106
106
  _: {
107
- tableName: "migration_state";
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: "direction";
115
+ fieldName: "migrationId";
121
116
  };
122
117
  };
123
- updatedAt: ConvexNumberBuilderInitial<""> & {
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: "updatedAt";
128
+ fieldName: "checksum";
134
129
  };
135
130
  };
136
- migrationId: ConvexTextBuilderInitial<""> & {
131
+ applied: ConvexBooleanBuilderInitial<""> & {
137
132
  _: {
138
133
  notNull: true;
139
134
  };
@@ -143,42 +138,34 @@ declare const migrationStorageTables: {
143
138
  };
144
139
  } & {
145
140
  _: {
146
- fieldName: "migrationId";
141
+ fieldName: "applied";
147
142
  };
148
143
  };
149
- checksum: ConvexTextBuilderInitial<""> & {
150
- _: {
151
- notNull: true;
152
- };
153
- } & {
144
+ direction: ConvexTextBuilderInitial<""> & {
154
145
  _: {
155
146
  tableName: "migration_state";
156
147
  };
157
148
  } & {
158
149
  _: {
159
- fieldName: "checksum";
150
+ fieldName: "direction";
160
151
  };
161
152
  };
162
- applied: ConvexBooleanBuilderInitial<""> & {
163
- _: {
164
- notNull: true;
165
- };
166
- } & {
153
+ runId: ConvexTextBuilderInitial<""> & {
167
154
  _: {
168
155
  tableName: "migration_state";
169
156
  };
170
157
  } & {
171
158
  _: {
172
- fieldName: "applied";
159
+ fieldName: "runId";
173
160
  };
174
161
  };
175
- runId: ConvexTextBuilderInitial<""> & {
162
+ cursor: ConvexTextBuilderInitial<""> & {
176
163
  _: {
177
164
  tableName: "migration_state";
178
165
  };
179
166
  } & {
180
167
  _: {
181
- fieldName: "runId";
168
+ fieldName: "cursor";
182
169
  };
183
170
  };
184
171
  processed: ConvexNumberBuilderInitial<""> & {
@@ -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
- updatedAt: ConvexNumberBuilderInitial<""> & {
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: "updatedAt";
282
+ fieldName: "runId";
283
283
  };
284
284
  };
285
- runId: ConvexTextBuilderInitial<""> & {
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: "runId";
295
+ fieldName: "startedAt";
296
296
  };
297
297
  };
298
- startedAt: ConvexNumberBuilderInitial<""> & {
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: "startedAt";
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
- count: ConvexNumberBuilderInitial<""> & {
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: "count";
1021
+ fieldName: "updatedAt";
1022
1022
  };
1023
1023
  };
1024
- updatedAt: ConvexNumberBuilderInitial<""> & {
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: "updatedAt";
1034
+ fieldName: "count";
1035
1035
  };
1036
1036
  };
1037
- tableKey: ConvexTextBuilderInitial<""> & {
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: "tableKey";
1047
+ fieldName: "indexName";
1048
1048
  };
1049
1049
  };
1050
- indexName: ConvexTextBuilderInitial<""> & {
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: "indexName";
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
- kind: ConvexTextBuilderInitial<""> & {
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: "kind";
1146
+ fieldName: "updatedAt";
1147
1147
  };
1148
1148
  };
1149
- updatedAt: ConvexNumberBuilderInitial<""> & {
1149
+ kind: ConvexTextBuilderInitial<""> & {
1150
1150
  _: {
1151
1151
  notNull: true;
1152
1152
  };
@@ -1156,10 +1156,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1156
1156
  };
1157
1157
  } & {
1158
1158
  _: {
1159
- fieldName: "updatedAt";
1159
+ fieldName: "kind";
1160
1160
  };
1161
1161
  };
1162
- tableKey: ConvexTextBuilderInitial<""> & {
1162
+ indexName: 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: "tableKey";
1172
+ fieldName: "indexName";
1173
1173
  };
1174
1174
  };
1175
- indexName: ConvexTextBuilderInitial<""> & {
1175
+ tableKey: 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: "indexName";
1185
+ fieldName: "tableKey";
1186
1186
  };
1187
1187
  };
1188
1188
  keyHash: 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
- value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
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: "value";
1336
+ fieldName: "updatedAt";
1341
1337
  };
1342
1338
  };
1343
- count: ConvexNumberBuilderInitial<""> & {
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: "count";
1353
+ fieldName: "value";
1354
1354
  };
1355
1355
  };
1356
- updatedAt: ConvexNumberBuilderInitial<""> & {
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: "updatedAt";
1366
+ fieldName: "count";
1367
1367
  };
1368
1368
  };
1369
- tableKey: ConvexTextBuilderInitial<""> & {
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: "tableKey";
1379
+ fieldName: "indexName";
1380
1380
  };
1381
1381
  };
1382
- indexName: ConvexTextBuilderInitial<""> & {
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: "indexName";
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";
@@ -1611,7 +1598,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1611
1598
  fieldName: "cursor";
1612
1599
  };
1613
1600
  };
1614
- updatedAt: ConvexNumberBuilderInitial<""> & {
1601
+ processed: ConvexNumberBuilderInitial<""> & {
1615
1602
  _: {
1616
1603
  notNull: true;
1617
1604
  };
@@ -1621,10 +1608,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1621
1608
  };
1622
1609
  } & {
1623
1610
  _: {
1624
- fieldName: "updatedAt";
1611
+ fieldName: "processed";
1625
1612
  };
1626
1613
  };
1627
- processed: ConvexNumberBuilderInitial<""> & {
1614
+ startedAt: ConvexNumberBuilderInitial<""> & {
1628
1615
  _: {
1629
1616
  notNull: true;
1630
1617
  };
@@ -1634,10 +1621,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1634
1621
  };
1635
1622
  } & {
1636
1623
  _: {
1637
- fieldName: "processed";
1624
+ fieldName: "startedAt";
1638
1625
  };
1639
1626
  };
1640
- startedAt: ConvexNumberBuilderInitial<""> & {
1627
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1641
1628
  _: {
1642
1629
  notNull: true;
1643
1630
  };
@@ -1647,7 +1634,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1647
1634
  };
1648
1635
  } & {
1649
1636
  _: {
1650
- fieldName: "startedAt";
1637
+ fieldName: "updatedAt";
1651
1638
  };
1652
1639
  };
1653
1640
  completedAt: ConvexNumberBuilderInitial<""> & {
@@ -1668,7 +1655,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1668
1655
  fieldName: "lastError";
1669
1656
  };
1670
1657
  };
1671
- tableKey: ConvexTextBuilderInitial<""> & {
1658
+ kind: ConvexTextBuilderInitial<""> & {
1672
1659
  _: {
1673
1660
  notNull: true;
1674
1661
  };
@@ -1678,7 +1665,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1678
1665
  };
1679
1666
  } & {
1680
1667
  _: {
1681
- fieldName: "tableKey";
1668
+ fieldName: "kind";
1682
1669
  };
1683
1670
  };
1684
1671
  indexName: ConvexTextBuilderInitial<""> & {
@@ -1720,6 +1707,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1720
1707
  fieldName: "metricDefinitionHash";
1721
1708
  };
1722
1709
  };
1710
+ tableKey: ConvexTextBuilderInitial<""> & {
1711
+ _: {
1712
+ notNull: true;
1713
+ };
1714
+ } & {
1715
+ _: {
1716
+ tableName: "aggregate_state";
1717
+ };
1718
+ } & {
1719
+ _: {
1720
+ fieldName: "tableKey";
1721
+ };
1722
+ };
1723
1723
  };
1724
1724
  }, {
1725
1725
  by_creation_time: ["_creationTime"];
@@ -1744,25 +1744,20 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1744
1744
  fieldName: "status";
1745
1745
  };
1746
1746
  };
1747
- cursor: ConvexTextBuilderInitial<""> & {
1747
+ migrationId: ConvexTextBuilderInitial<""> & {
1748
1748
  _: {
1749
- tableName: "migration_state";
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: "direction";
1757
+ fieldName: "migrationId";
1763
1758
  };
1764
1759
  };
1765
- updatedAt: ConvexNumberBuilderInitial<""> & {
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: "updatedAt";
1770
+ fieldName: "checksum";
1776
1771
  };
1777
1772
  };
1778
- migrationId: ConvexTextBuilderInitial<""> & {
1773
+ applied: ConvexBooleanBuilderInitial<""> & {
1779
1774
  _: {
1780
1775
  notNull: true;
1781
1776
  };
@@ -1785,42 +1780,34 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1785
1780
  };
1786
1781
  } & {
1787
1782
  _: {
1788
- fieldName: "migrationId";
1783
+ fieldName: "applied";
1789
1784
  };
1790
1785
  };
1791
- checksum: ConvexTextBuilderInitial<""> & {
1792
- _: {
1793
- notNull: true;
1794
- };
1795
- } & {
1786
+ direction: ConvexTextBuilderInitial<""> & {
1796
1787
  _: {
1797
1788
  tableName: "migration_state";
1798
1789
  };
1799
1790
  } & {
1800
1791
  _: {
1801
- fieldName: "checksum";
1792
+ fieldName: "direction";
1802
1793
  };
1803
1794
  };
1804
- applied: ConvexBooleanBuilderInitial<""> & {
1805
- _: {
1806
- notNull: true;
1807
- };
1808
- } & {
1795
+ runId: ConvexTextBuilderInitial<""> & {
1809
1796
  _: {
1810
1797
  tableName: "migration_state";
1811
1798
  };
1812
1799
  } & {
1813
1800
  _: {
1814
- fieldName: "applied";
1801
+ fieldName: "runId";
1815
1802
  };
1816
1803
  };
1817
- runId: ConvexTextBuilderInitial<""> & {
1804
+ cursor: ConvexTextBuilderInitial<""> & {
1818
1805
  _: {
1819
1806
  tableName: "migration_state";
1820
1807
  };
1821
1808
  } & {
1822
1809
  _: {
1823
- fieldName: "runId";
1810
+ fieldName: "cursor";
1824
1811
  };
1825
1812
  };
1826
1813
  processed: ConvexNumberBuilderInitial<""> & {
@@ -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
- updatedAt: ConvexNumberBuilderInitial<""> & {
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: "updatedAt";
1924
+ fieldName: "runId";
1925
1925
  };
1926
1926
  };
1927
- runId: ConvexTextBuilderInitial<""> & {
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: "runId";
1937
+ fieldName: "startedAt";
1938
1938
  };
1939
1939
  };
1940
- startedAt: ConvexNumberBuilderInitial<""> & {
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: "startedAt";
1950
+ fieldName: "updatedAt";
1951
1951
  };
1952
1952
  };
1953
1953
  completedAt: ConvexNumberBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.27.2",
3
+ "version": "0.27.4",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -69,7 +69,7 @@
69
69
  "common-tags": "^1.8.2",
70
70
  "diff": "^8.0.2",
71
71
  "dotenv": "^17.3.1",
72
- "esbuild": "^0.27.3",
72
+ "esbuild": "^0.27.7",
73
73
  "execa": "^9.6.1",
74
74
  "jiti": "^2.6.1",
75
75
  "jotai": "^2.18.0",
@@ -644,6 +644,12 @@ bunx kitcn aggregate backfill --prod
644
644
  bunx kitcn analyze
645
645
  ```
646
646
 
647
+ `kitcn analyze` ranks each Convex function by the isolate it deploys into.
648
+ `OutMB` is that isolate's bundled size; `DepMB`/`LocMB` are the source size of
649
+ the dependency and own-Convex files inside it; `Files` counts the files
650
+ contributing bytes to it. A file that is imported but fully tree-shaken away is
651
+ counted in none of them. Use `--deploy` for deployment totals instead.
652
+
647
653
  Concave lane:
648
654
 
649
655
  ```bash