kitcn 0.17.2 → 0.17.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/dist/watcher.mjs CHANGED
@@ -1,12 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import { At as PARSE_SNAPSHOT_SUFFIX, Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-KwJ5FZgj.mjs";
2
+ import { a as generateMeta, c as PARSE_SNAPSHOT_SUFFIX, i as resolveConfiguredBackend, n as withLocalCodegenEnv, o as getConvexConfig, r as loadCliConfig, s as logger } from "./local-env-DykABjCt.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  //#region src/cli/watcher.ts
7
+ function getConvexRoot(functionsDir) {
8
+ const projectDir = path.resolve(process.cwd());
9
+ const relativeFunctionsDir = path.relative(projectDir, functionsDir);
10
+ return relativeFunctionsDir.includes(path.sep) && relativeFunctionsDir !== ".." && !relativeFunctionsDir.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeFunctionsDir) ? path.dirname(functionsDir) : functionsDir;
11
+ }
7
12
  function getWatchRoots(functionsDir) {
8
- const convexDir = path.dirname(functionsDir);
9
- return [functionsDir, path.join(convexDir, "routers")];
13
+ const functions = path.resolve(functionsDir);
14
+ const convexRoot = getConvexRoot(functions);
15
+ const roots = [
16
+ functions,
17
+ path.join(convexRoot, "routers"),
18
+ path.join(convexRoot, "lib"),
19
+ path.join(convexRoot, "shared")
20
+ ];
21
+ return roots.filter((root, index) => roots.indexOf(root) === index && !roots.some((other) => root.startsWith(`${other}${path.sep}`)));
10
22
  }
11
23
  function parseWatcherBackendEnv(value) {
12
24
  if (value === "convex" || value === "concave") return value;
@@ -47,10 +59,9 @@ function shouldIgnoreWatchPath(watchedPath, functionsDir, outputFile) {
47
59
  return normalizedPath.endsWith(".runtime.ts") || normalizedPath.endsWith(PARSE_SNAPSHOT_SUFFIX);
48
60
  }
49
61
  async function runWatcherCodegen(params, deps = {}) {
50
- const resolveRunDepsFn = deps.resolveRunDeps ?? resolveRunDeps;
51
62
  const resolveConfiguredBackendFn = deps.resolveConfiguredBackendFn ?? resolveConfiguredBackend;
52
- const { execa: execaFn, generateMeta: generateMetaFn, loadCliConfig: loadCliConfigFn } = resolveRunDepsFn();
53
- const config = loadCliConfigFn(params.configPath);
63
+ const generateMetaFn = deps.generateMeta ?? generateMeta;
64
+ const config = (deps.loadCliConfig ?? loadCliConfig)(params.configPath);
54
65
  const backend = resolveConfiguredBackendFn({
55
66
  backendArg: params.backendArg,
56
67
  config
@@ -78,7 +89,7 @@ async function runWatcherCodegen(params, deps = {}) {
78
89
  if (params.sharedDir) args.push("--api", params.sharedDir);
79
90
  if (params.configPath) args.push("--config", params.configPath);
80
91
  if (params.debug) args.push("--debug");
81
- const result = await execaFn(runtime, args, {
92
+ const result = await (deps.execa ?? (await import("execa")).execa)(runtime, args, {
82
93
  cwd: process.cwd(),
83
94
  reject: false,
84
95
  stdio: "pipe"
@@ -2275,6 +2275,11 @@ declare class ConvexDeleteBuilder<TTable extends ConvexTable<any>, TReturning ex
2275
2275
  private scheduledDelayMs?;
2276
2276
  private executionModeOverride?;
2277
2277
  private paginateConfig?;
2278
+ private _returningCountLoader?;
2279
+ /**
2280
+ * One loader per statement: the table config, edge filter and aggregate-index
2281
+ * readiness memo are invariant across the affected rows.
2282
+ */
2278
2283
  private _loadReturningCount;
2279
2284
  constructor(db: GenericDatabaseWriter<any>, table: TTable);
2280
2285
  where(expression: FilterExpression$1<boolean>): ConvexDeleteBuilder<TTable, TReturning, TMode, true>;
@@ -2319,6 +2324,11 @@ declare class ConvexInsertBuilder<TTable extends ConvexTable<any>, TReturning ex
2319
2324
  private returningFields?;
2320
2325
  private conflictConfig?;
2321
2326
  private allowFullScanFlag;
2327
+ private _returningCountLoader?;
2328
+ /**
2329
+ * One loader per statement: the table config, edge filter and aggregate-index
2330
+ * readiness memo are invariant across the affected rows.
2331
+ */
2322
2332
  private _loadReturningCount;
2323
2333
  constructor(db: GenericDatabaseWriter<any>, table: TTable);
2324
2334
  values(values: InsertValue<TTable> | InsertValue<TTable>[]): this;
@@ -2411,12 +2421,38 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
2411
2421
  readonly result: TResult;
2412
2422
  };
2413
2423
  private allowFullScan;
2424
+ /**
2425
+ * Set synchronously by the first `execute()`. Later executions run on a fresh
2426
+ * instance instead, which is what keeps execution-scoped state from leaking
2427
+ * between two awaits of the same query object.
2428
+ */
2429
+ private _executionClaimed;
2430
+ /**
2431
+ * Scoped to one execution, because `_executionClaimed` diverts every later
2432
+ * execution to its own instance. Within a run, every `_applyRlsSelectFilter`
2433
+ * call shares it, including the streaming sites that pass a single row at a
2434
+ * time — those would otherwise re-resolve the whole policy set per row.
2435
+ *
2436
+ * SECURITY: a resolved policy expression can embed database state that a
2437
+ * later write invalidates, so it must never outlive the execution that
2438
+ * resolved it.
2439
+ */
2440
+ private readonly _rlsPolicyResolution;
2441
+ /**
2442
+ * Assigned in the constructor so callers that run many short-lived query
2443
+ * instances against the same tables (mutation `returning({ _count })`) can
2444
+ * share one readiness memo instead of re-probing per instance.
2445
+ */
2414
2446
  private readonly _countIndexReadinessByKey;
2415
- private readonly _aggregateIndexReadinessByKey;
2447
+ /**
2448
+ * Index readiness is a probe memo, not execution state, so `_forExecution`
2449
+ * hands it to the next run rather than re-probing.
2450
+ */
2451
+ private _aggregateIndexReadinessByKey;
2416
2452
  constructor(schema: TSchema, tableConfig: TTableConfig, edgeMetadata: EdgeMetadata[], db: GenericDatabaseReader<any>, config: DBQueryConfig<'one' | 'many', boolean, TSchema, TTableConfig>, mode: 'many' | 'first' | 'firstOrThrow' | 'count' | 'aggregate' | 'groupBy', _allEdges?: EdgeMetadata[] | undefined, // M6.5 Phase 2: All edges for nested loading
2417
2453
  rls?: RlsContext | undefined, relationLoading?: {
2418
2454
  concurrency?: number;
2419
- } | undefined, vectorSearchProvider?: VectorSearchProvider | undefined, configuredIndex?: PredicateWhereIndexConfig<TTableConfig> | undefined);
2455
+ } | undefined, vectorSearchProvider?: VectorSearchProvider | undefined, configuredIndex?: PredicateWhereIndexConfig<TTableConfig> | undefined, countIndexReadiness?: Map<string, Promise<void>>);
2420
2456
  private _usesSystemCreatedAtAlias;
2421
2457
  private _assertNoLegacyPublicFieldName;
2422
2458
  private _normalizePublicFieldName;
@@ -2564,6 +2600,11 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
2564
2600
  private _coerceGroupByConfig;
2565
2601
  private _buildAggregateMetricConfig;
2566
2602
  private _executeGroupBy;
2603
+ /**
2604
+ * A second instance of the same query: identical configuration, its own
2605
+ * execution-scoped state, the same index-readiness memos.
2606
+ */
2607
+ private _forExecution;
2567
2608
  /**
2568
2609
  * Execute the query and return results
2569
2610
  * Phase 4 implementation with WhereClauseCompiler integration
@@ -2933,6 +2974,11 @@ declare class ConvexUpdateBuilder<TTable extends ConvexTable<any>, TReturning ex
2933
2974
  private allowFullScanFlag;
2934
2975
  private paginateConfig?;
2935
2976
  private executionModeOverride?;
2977
+ private _returningCountLoader?;
2978
+ /**
2979
+ * One loader per statement: the table config, edge filter and aggregate-index
2980
+ * readiness memo are invariant across the affected rows.
2981
+ */
2936
2982
  private _loadReturningCount;
2937
2983
  constructor(db: GenericDatabaseWriter<any>, table: TTable);
2938
2984
  set(values: UpdateSet<TTable>): this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",