kitcn 0.12.8 → 0.12.9

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.
@@ -1,4 +1,4 @@
1
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-DdjN63Io.js";
1
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-Dw3EVdi6.js";
2
2
  import * as convex_values0 from "convex/values";
3
3
  import { GenericId, Infer, Value } from "convex/values";
4
4
  import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
package/dist/cli.mjs CHANGED
@@ -1950,7 +1950,10 @@ const CONVEX_MANAGED_ENV_KEYS = new Set([
1950
1950
  "NEXT_PUBLIC_CONVEX_URL",
1951
1951
  "VITE_CONVEX_URL"
1952
1952
  ]);
1953
- const defaultRunCommand = async (args, cwd) => runLocalConvexCommand(args, { cwd });
1953
+ const defaultRunCommand = async (args, cwd, env) => runLocalConvexCommand(args, {
1954
+ cwd,
1955
+ env
1956
+ });
1954
1957
  const generateAuthSecret = () => randomBytes(32).toString("base64url");
1955
1958
  const defaultSecretGenerator = () => generateAuthSecret();
1956
1959
  const normalizeRelativePath = (cwd, filePath) => path.relative(cwd, filePath).replaceAll("\\", "/") || ".";
@@ -2015,8 +2018,8 @@ const ensureAuthSecret = (params) => {
2015
2018
  if (!params.silent) logger.info("Generated BETTER_AUTH_SECRET in convex/.env");
2016
2019
  return secret;
2017
2020
  };
2018
- const runConvexCommand = async (runCommand, cwd, args) => {
2019
- const result = await runCommand(args, cwd);
2021
+ const runConvexCommand = async (runCommand, cwd, args, env) => {
2022
+ const result = await runCommand(args, cwd, env);
2020
2023
  if (result.exitCode !== 0) throw new Error(formatConvexCommandFailure(args, result));
2021
2024
  return result;
2022
2025
  };
@@ -2069,6 +2072,7 @@ async function pushEnv(options = {}, deps = {}) {
2069
2072
  const rotate = options.rotate ?? false;
2070
2073
  const silent = options.silent ?? false;
2071
2074
  const targetArgs = options.targetArgs ?? [];
2075
+ const commandEnv = options.commandEnv;
2072
2076
  const runCommand = deps.runCommand ?? defaultRunCommand;
2073
2077
  const secretGenerator = deps.secretGenerator ?? defaultSecretGenerator;
2074
2078
  const envPath = path.join(cwd, "convex", ".env");
@@ -2096,7 +2100,7 @@ async function pushEnv(options = {}, deps = {}) {
2096
2100
  envFilePath: tempEnvPath,
2097
2101
  force,
2098
2102
  targetArgs
2099
- }));
2103
+ }), commandEnv);
2100
2104
  return true;
2101
2105
  } finally {
2102
2106
  fs.rmSync(tempDir, {
@@ -2144,14 +2148,14 @@ async function pushEnv(options = {}, deps = {}) {
2144
2148
  "run",
2145
2149
  AUTH_ROTATE_KEYS_FUNCTION,
2146
2150
  ...targetArgs
2147
- ]);
2151
+ ], commandEnv);
2148
2152
  if (!silent) logger.info("Rotated auth keys.");
2149
2153
  }
2150
2154
  nextVars.JWKS = parseConvexRunValue((await runConvexCommand(runCommand, cwd, [
2151
2155
  "run",
2152
2156
  AUTH_JWKS_FUNCTION,
2153
2157
  ...targetArgs
2154
- ])).stdout);
2158
+ ], commandEnv)).stdout);
2155
2159
  await finalizePush();
2156
2160
  return;
2157
2161
  }
@@ -2169,23 +2173,26 @@ async function pushEnv(options = {}, deps = {}) {
2169
2173
  "run",
2170
2174
  AUTH_ROTATE_KEYS_FUNCTION,
2171
2175
  ...targetArgs
2172
- ]);
2176
+ ], commandEnv);
2173
2177
  if (!silent) logger.info("Rotated auth keys.");
2174
2178
  }
2175
2179
  nextVars.JWKS = parseConvexRunValue((await runConvexCommand(runCommand, cwd, [
2176
2180
  "run",
2177
2181
  AUTH_JWKS_FUNCTION,
2178
2182
  ...targetArgs
2179
- ])).stdout);
2183
+ ], commandEnv)).stdout);
2180
2184
  await finalizePush();
2181
2185
  }
2182
2186
  async function pullEnv(options = {}, deps = {}) {
2183
2187
  const cwd = process.cwd();
2184
- const result = await runConvexCommand(deps.runCommand ?? defaultRunCommand, cwd, [
2188
+ const runCommand = deps.runCommand ?? defaultRunCommand;
2189
+ const targetArgs = options.targetArgs ?? [];
2190
+ const commandEnv = options.commandEnv;
2191
+ const result = await runConvexCommand(runCommand, cwd, [
2185
2192
  "env",
2186
2193
  "list",
2187
- ...options.targetArgs ?? []
2188
- ]);
2194
+ ...targetArgs
2195
+ ], commandEnv);
2189
2196
  if (options.outFilePath) {
2190
2197
  const outputPath = path.resolve(cwd, options.outFilePath);
2191
2198
  fs.mkdirSync(path.dirname(outputPath), { recursive: true });
@@ -9206,6 +9213,7 @@ const CONVEX_DEPLOYMENT_ENV_KEYS = [
9206
9213
  "CONVEX_SELF_HOSTED_URL",
9207
9214
  "CONVEX_SELF_HOSTED_ADMIN_KEY"
9208
9215
  ];
9216
+ const LOCAL_CONVEX_DEPLOYMENT_PREFIXES = ["local:", "anonymous:"];
9209
9217
  function createBackendCommandEnv(overrides) {
9210
9218
  const clearedDeploymentEnv = Object.fromEntries(CONVEX_DEPLOYMENT_ENV_KEYS.map((key) => [key, void 0]));
9211
9219
  return {
@@ -9214,6 +9222,26 @@ function createBackendCommandEnv(overrides) {
9214
9222
  ...overrides
9215
9223
  };
9216
9224
  }
9225
+ function hasRemoteConvexDeploymentEnv(env) {
9226
+ const deployment = env.CONVEX_DEPLOYMENT?.trim();
9227
+ if (deployment && !LOCAL_CONVEX_DEPLOYMENT_PREFIXES.some((prefix) => deployment.startsWith(prefix))) return true;
9228
+ return Boolean(env.CONVEX_DEPLOY_KEY?.trim() || env.CONVEX_SELF_HOSTED_URL?.trim() || env.CONVEX_SELF_HOSTED_ADMIN_KEY?.trim());
9229
+ }
9230
+ function readConvexTargetEnvFile(args, cwd = process.cwd()) {
9231
+ const envFile = readOptionalCliFlagValue(args, "--env-file");
9232
+ if (!envFile) return null;
9233
+ const envFilePath = resolve(cwd, envFile);
9234
+ if (!fs.existsSync(envFilePath)) return null;
9235
+ return parse(fs.readFileSync(envFilePath, "utf8"));
9236
+ }
9237
+ function resolveRemoteConvexDeploymentKey(env) {
9238
+ if (!hasRemoteConvexDeploymentEnv(env)) return null;
9239
+ const deployment = env.CONVEX_DEPLOYMENT?.trim();
9240
+ if (deployment) return `deployment-env:${deployment}`;
9241
+ const selfHostedUrl = env.CONVEX_SELF_HOSTED_URL?.trim();
9242
+ if (selfHostedUrl) return `self-hosted-env:${selfHostedUrl}`;
9243
+ return "remote-env";
9244
+ }
9217
9245
  async function withLocalConvexEnv(sharedDir, fn) {
9218
9246
  const { functionsDir } = getConvexConfig(sharedDir);
9219
9247
  const envPath = join(functionsDir, "..", ".env");
@@ -10612,12 +10640,19 @@ function writeAggregateFingerprintState(statePath, state) {
10612
10640
  fs.writeFileSync(tmpPath, JSON.stringify(state, null, 2));
10613
10641
  fs.renameSync(tmpPath, statePath);
10614
10642
  }
10615
- function getAggregateBackfillDeploymentKey(args) {
10643
+ function getAggregateBackfillDeploymentKey(args, cwd = process.cwd(), env) {
10616
10644
  if (args.includes("--prod")) return "prod";
10617
10645
  const deploymentName = readOptionalCliFlagValue(args, "--deployment-name");
10618
10646
  if (deploymentName) return `deployment:${deploymentName}`;
10619
10647
  const previewName = readOptionalCliFlagValue(args, "--preview-name");
10620
10648
  if (previewName) return `preview:${previewName}`;
10649
+ const envKey = env ? resolveRemoteConvexDeploymentKey(env) : null;
10650
+ if (envKey) return envKey;
10651
+ const envFileVars = readConvexTargetEnvFile(args, cwd);
10652
+ if (envFileVars) {
10653
+ const envFileKey = resolveRemoteConvexDeploymentKey(envFileVars);
10654
+ if (envFileKey) return envFileKey;
10655
+ }
10621
10656
  return "local";
10622
10657
  }
10623
10658
  function ensureConvexGitignoreEntry(cwd = process.cwd()) {
@@ -10825,9 +10860,6 @@ function buildCodegenBootstrapArgs(targetArgs) {
10825
10860
  function didConvexInitCreateConfiguration(output) {
10826
10861
  return CONVEX_INIT_CREATED_CONFIG_RE.test(output);
10827
10862
  }
10828
- function hasRemoteConvexInitTargetArgs(targetArgs) {
10829
- return targetArgs?.some((arg) => arg === "--prod" || arg === "--preview-name" || arg === "--deployment-name") ?? false;
10830
- }
10831
10863
  async function runConvexInitIfNeeded(params) {
10832
10864
  if (params.backendAdapter.publicName !== "convex") return {
10833
10865
  created: false,
@@ -10835,7 +10867,7 @@ async function runConvexInitIfNeeded(params) {
10835
10867
  stdout: "",
10836
10868
  stderr: ""
10837
10869
  };
10838
- const agentModeOverride = params.yes && !hasRemoteConvexInitTargetArgs(params.targetArgs) ? "anonymous" : params.env?.CONVEX_AGENT_MODE;
10870
+ const agentModeOverride = params.yes && getAggregateBackfillDeploymentKey(params.targetArgs ?? [], process.cwd(), params.env) === "local" ? "anonymous" : params.env?.CONVEX_AGENT_MODE;
10839
10871
  const result = normalizeConvexCommandResult(await params.execaFn(params.backendAdapter.command, [
10840
10872
  ...params.backendAdapter.argsPrefix,
10841
10873
  "init",
@@ -11449,7 +11481,7 @@ async function runBackendFunction(execaFn, backendAdapter, functionName, args, t
11449
11481
  JSON.stringify(args)
11450
11482
  ], {
11451
11483
  cwd: process.cwd(),
11452
- env: createBackendCommandEnv(),
11484
+ env: createBackendCommandEnv(options?.env),
11453
11485
  reject: false,
11454
11486
  stdio: "pipe"
11455
11487
  });
@@ -11466,13 +11498,16 @@ async function runBackendFunction(execaFn, backendAdapter, functionName, args, t
11466
11498
  };
11467
11499
  }
11468
11500
  async function runAggregateBackfillFlow(params) {
11469
- const { execaFn, backendAdapter, backfillConfig, mode, targetArgs, signal, context } = params;
11501
+ const { execaFn, backendAdapter, backfillConfig, mode, targetArgs, env, signal, context } = params;
11470
11502
  if (signal?.aborted) return 0;
11471
11503
  if (backfillConfig.enabled === "off") return 0;
11472
11504
  const kickoff = await runBackendFunction(execaFn, backendAdapter, "generated/server:aggregateBackfill", {
11473
11505
  mode,
11474
11506
  batchSize: backfillConfig.batchSize
11475
- }, targetArgs, { echoOutput: false });
11507
+ }, targetArgs, {
11508
+ echoOutput: false,
11509
+ env
11510
+ });
11476
11511
  if (kickoff.exitCode !== 0) {
11477
11512
  const combinedOutput = `${kickoff.stdout}\n${kickoff.stderr}`;
11478
11513
  if (backfillConfig.enabled === "auto" && isMissingBackfillFunctionOutput(combinedOutput)) {
@@ -11499,7 +11534,10 @@ async function runAggregateBackfillFlow(params) {
11499
11534
  const deadline = Date.now() + backfillConfig.timeoutMs;
11500
11535
  let lastProgress = "";
11501
11536
  while (!signal?.aborted) {
11502
- const statusResult = await runBackendFunction(execaFn, backendAdapter, "generated/server:aggregateBackfillStatus", {}, targetArgs, { echoOutput: false });
11537
+ const statusResult = await runBackendFunction(execaFn, backendAdapter, "generated/server:aggregateBackfillStatus", {}, targetArgs, {
11538
+ echoOutput: false,
11539
+ env
11540
+ });
11503
11541
  if (statusResult.exitCode !== 0) return statusResult.exitCode;
11504
11542
  const statuses = parseBackendRunJson(statusResult.stdout);
11505
11543
  const failed = statuses.find((entry) => Boolean(entry.lastError));
@@ -11634,7 +11672,7 @@ export const migration = defineMigration({
11634
11672
  logger.info(`manifest: ${manifestFile}`);
11635
11673
  }
11636
11674
  async function runMigrationFlow(params) {
11637
- const { execaFn, backendAdapter, migrationConfig, targetArgs, signal, context, direction, steps, to } = params;
11675
+ const { execaFn, backendAdapter, migrationConfig, targetArgs, env, signal, context, direction, steps, to } = params;
11638
11676
  if (signal?.aborted || migrationConfig.enabled === "off") return 0;
11639
11677
  const kickoff = await runBackendFunction(execaFn, backendAdapter, "generated/server:migrationRun", {
11640
11678
  direction,
@@ -11642,7 +11680,10 @@ async function runMigrationFlow(params) {
11642
11680
  allowDrift: migrationConfig.allowDrift,
11643
11681
  ...steps !== void 0 ? { steps } : {},
11644
11682
  ...to !== void 0 ? { to } : {}
11645
- }, targetArgs, { echoOutput: false });
11683
+ }, targetArgs, {
11684
+ echoOutput: false,
11685
+ env
11686
+ });
11646
11687
  if (kickoff.exitCode !== 0) {
11647
11688
  const combinedOutput = `${kickoff.stdout}\n${kickoff.stderr}`;
11648
11689
  if (migrationConfig.enabled === "auto" && isMissingBackfillFunctionOutput(combinedOutput)) {
@@ -11677,7 +11718,10 @@ async function runMigrationFlow(params) {
11677
11718
  const deadline = Date.now() + migrationConfig.timeoutMs;
11678
11719
  let lastStatusLine = "";
11679
11720
  while (!signal?.aborted) {
11680
- const statusResult = await runBackendFunction(execaFn, backendAdapter, "generated/server:migrationStatus", { runId }, targetArgs, { echoOutput: false });
11721
+ const statusResult = await runBackendFunction(execaFn, backendAdapter, "generated/server:migrationStatus", { runId }, targetArgs, {
11722
+ echoOutput: false,
11723
+ env
11724
+ });
11681
11725
  if (statusResult.exitCode !== 0) return statusResult.exitCode;
11682
11726
  const statusPayload = parseBackendRunJson(statusResult.stdout);
11683
11727
  const runStatus = typeof statusPayload === "object" && statusPayload !== null && !Array.isArray(statusPayload) ? statusPayload.activeRun?.status ?? statusPayload.runs?.[0]?.status ?? "unknown" : "unknown";
@@ -11712,10 +11756,10 @@ async function runMigrationFlow(params) {
11712
11756
  return 0;
11713
11757
  }
11714
11758
  async function runDevSchemaBackfillIfNeeded(params) {
11715
- const { execaFn, backendAdapter, backfillConfig, functionsDir, targetArgs, signal } = params;
11759
+ const { execaFn, backendAdapter, backfillConfig, functionsDir, targetArgs, env, signal } = params;
11716
11760
  const fingerprint = await computeAggregateIndexFingerprint(functionsDir);
11717
11761
  if (!fingerprint) return 0;
11718
- const deploymentKey = getAggregateBackfillDeploymentKey(targetArgs);
11762
+ const deploymentKey = getAggregateBackfillDeploymentKey(targetArgs, process.cwd(), env);
11719
11763
  const statePath = getDevAggregateBackfillStatePath();
11720
11764
  const state = readAggregateFingerprintState(statePath);
11721
11765
  if (state.entries[deploymentKey]?.fingerprint === fingerprint) return 0;
@@ -11729,6 +11773,7 @@ async function runDevSchemaBackfillIfNeeded(params) {
11729
11773
  },
11730
11774
  mode: "resume",
11731
11775
  targetArgs,
11776
+ env,
11732
11777
  signal,
11733
11778
  context: "dev"
11734
11779
  });
@@ -12087,6 +12132,59 @@ function resolveConcaveLocalSiteUrl(cwd = process.cwd()) {
12087
12132
  const parsed = parseEnv(fs.readFileSync(envLocalPath, "utf8"));
12088
12133
  return parsed.NEXT_PUBLIC_SITE_URL ?? parsed.VITE_SITE_URL ?? "http://localhost:3000";
12089
12134
  }
12135
+ function resolveImplicitConvexRemoteDeploymentEnv(cwd = process.cwd()) {
12136
+ const envLocalPath = join(cwd, ".env.local");
12137
+ if (!fs.existsSync(envLocalPath)) return null;
12138
+ const parsed = parseEnv(fs.readFileSync(envLocalPath, "utf8"));
12139
+ if (!hasRemoteConvexDeploymentEnv(parsed)) return null;
12140
+ return {
12141
+ CONVEX_DEPLOYMENT: parsed.CONVEX_DEPLOYMENT,
12142
+ CONVEX_DEPLOY_KEY: parsed.CONVEX_DEPLOY_KEY,
12143
+ CONVEX_SELF_HOSTED_URL: parsed.CONVEX_SELF_HOSTED_URL,
12144
+ CONVEX_SELF_HOSTED_ADMIN_KEY: parsed.CONVEX_SELF_HOSTED_ADMIN_KEY
12145
+ };
12146
+ }
12147
+ function resolveConvexEnvFileCommandEnv(args, cwd = process.cwd()) {
12148
+ let envFilePath = null;
12149
+ for (let i = 0; i < args.length; i += 1) {
12150
+ const arg = args[i];
12151
+ if (arg === "--env-file") {
12152
+ envFilePath = args[i + 1] ?? null;
12153
+ break;
12154
+ }
12155
+ if (arg.startsWith("--env-file=")) {
12156
+ envFilePath = arg.slice(11) || null;
12157
+ break;
12158
+ }
12159
+ }
12160
+ if (!envFilePath) return null;
12161
+ const resolvedPath = resolve(cwd, envFilePath);
12162
+ if (!fs.existsSync(resolvedPath)) return null;
12163
+ const parsed = parseEnv(fs.readFileSync(resolvedPath, "utf8"));
12164
+ return {
12165
+ CONVEX_DEPLOYMENT: parsed.CONVEX_DEPLOYMENT,
12166
+ CONVEX_DEPLOY_KEY: parsed.CONVEX_DEPLOY_KEY,
12167
+ CONVEX_SELF_HOSTED_URL: parsed.CONVEX_SELF_HOSTED_URL,
12168
+ CONVEX_SELF_HOSTED_ADMIN_KEY: parsed.CONVEX_SELF_HOSTED_ADMIN_KEY
12169
+ };
12170
+ }
12171
+ function stripConvexEnvFileTargetArgs(args) {
12172
+ const nextArgs = [];
12173
+ let skipNext = false;
12174
+ for (const arg of args) {
12175
+ if (skipNext) {
12176
+ skipNext = false;
12177
+ continue;
12178
+ }
12179
+ if (arg === "--env-file") {
12180
+ skipNext = true;
12181
+ continue;
12182
+ }
12183
+ if (arg.startsWith("--env-file=")) continue;
12184
+ nextArgs.push(arg);
12185
+ }
12186
+ return nextArgs;
12187
+ }
12090
12188
  const resolveWatcherCommand = (currentFilename = __filename$1, currentDir = __dirname) => {
12091
12189
  const isTs = currentFilename.endsWith(".ts");
12092
12190
  return {
@@ -12265,6 +12363,10 @@ const handleDevCommand = async (argv, deps) => {
12265
12363
  const debug = parsed.debug || config.dev.debug;
12266
12364
  assertNoRemovedDevPreRunFlag(config.dev.args);
12267
12365
  const { bootstrap, remainingArgs: convexDevArgs } = extractDevBootstrapCliFlag([...config.dev.args, ...devCommandArgs]);
12366
+ const explicitConvexTargetArgs = extractBackendRunTargetArgs("convex", convexDevArgs);
12367
+ const explicitConvexCommandEnv = resolveConvexEnvFileCommandEnv(convexDevArgs);
12368
+ const implicitConvexCommandEnv = backend === "convex" && explicitConvexTargetArgs.length === 0 && explicitConvexCommandEnv === null ? resolveImplicitConvexRemoteDeploymentEnv() : null;
12369
+ const effectiveConvexCommandEnv = explicitConvexCommandEnv ?? implicitConvexCommandEnv;
12268
12370
  const preRunFunction = config.dev.preRun;
12269
12371
  if (bootstrap && backend !== "convex") throw new Error("`kitcn dev --bootstrap` is only supported for backend convex.");
12270
12372
  if (preRunFunction && backend === "concave") throw new Error("`dev.preRun` is only supported for backend convex. Concave dev has no equivalent `--run` flow.");
@@ -12281,10 +12383,10 @@ const handleDevCommand = async (argv, deps) => {
12281
12383
  const concaveLocalDevContract = backend === "concave" ? resolveConcaveLocalDevContract(convexDevArgs, (deps?.resolveConcaveLocalSiteUrl ?? resolveConcaveLocalSiteUrl)(process.cwd())) : null;
12282
12384
  const backendDevArgs = concaveLocalDevContract?.backendArgs ?? applyConvexDevPreRunArgs(convexDevArgs, preRunFunction);
12283
12385
  const backendOutputMode = debug || backend === "convex" && !hasDevArg(backendDevArgs, "--once") ? "raw" : "filtered";
12284
- const targetArgs = concaveLocalDevContract?.targetArgs ?? extractBackendRunTargetArgs(backend, convexDevArgs);
12386
+ const targetArgs = concaveLocalDevContract?.targetArgs ?? stripConvexEnvFileTargetArgs(extractBackendRunTargetArgs(backend, convexDevArgs));
12285
12387
  const trimSegments = resolveCodegenTrimSegments(config);
12286
12388
  const localNodeEnvOverrides = backend === "convex" ? await resolveSupportedLocalNodeEnvOverridesFn({ execaFn }) : {};
12287
- if (!bootstrap && backend === "convex" && !debug) logger.info("Bootstrapping local Convex...");
12389
+ if (!bootstrap && backend === "convex" && !debug && getAggregateBackfillDeploymentKey(targetArgs, process.cwd(), effectiveConvexCommandEnv ?? void 0) === "local") logger.info("Bootstrapping local Convex...");
12288
12390
  if (bootstrap) return runLocalConvexBootstrap({
12289
12391
  authSyncMode: "complete",
12290
12392
  config,
@@ -12307,7 +12409,10 @@ const handleDevCommand = async (argv, deps) => {
12307
12409
  execaFn,
12308
12410
  backendAdapter,
12309
12411
  echoOutput: false,
12310
- env: localNodeEnvOverrides,
12412
+ env: {
12413
+ ...localNodeEnvOverrides,
12414
+ ...effectiveConvexCommandEnv
12415
+ },
12311
12416
  targetArgs
12312
12417
  });
12313
12418
  if (convexInitResult.exitCode !== 0) return convexInitResult.exitCode;
@@ -12318,6 +12423,7 @@ const handleDevCommand = async (argv, deps) => {
12318
12423
  });
12319
12424
  if (backend === "convex" && (fs.existsSync(localConvexEnvPath) || authEnvState.installed)) await syncEnvFn({
12320
12425
  authSyncMode: authEnvState.installed ? "prepare" : "skip",
12426
+ commandEnv: effectiveConvexCommandEnv ?? void 0,
12321
12427
  force: true,
12322
12428
  sharedDir,
12323
12429
  silent: true,
@@ -12353,6 +12459,7 @@ const handleDevCommand = async (argv, deps) => {
12353
12459
  cwd: process.cwd(),
12354
12460
  env: createBackendCommandEnv({
12355
12461
  ...localNodeEnvOverrides,
12462
+ ...effectiveConvexCommandEnv,
12356
12463
  ...concaveLocalDevContract?.backendEnv
12357
12464
  }),
12358
12465
  reject: false
@@ -12366,6 +12473,7 @@ const handleDevCommand = async (argv, deps) => {
12366
12473
  signal: backfillAbortController.signal,
12367
12474
  runTask: () => syncEnvFn({
12368
12475
  authSyncMode: "complete",
12476
+ commandEnv: effectiveConvexCommandEnv ?? void 0,
12369
12477
  force: true,
12370
12478
  sharedDir,
12371
12479
  silent: true,
@@ -12388,6 +12496,7 @@ const handleDevCommand = async (argv, deps) => {
12388
12496
  backendAdapter,
12389
12497
  backfillConfig: devBackfillConfig,
12390
12498
  functionsDir,
12499
+ env: effectiveConvexCommandEnv ?? void 0,
12391
12500
  targetArgs,
12392
12501
  signal: backfillAbortController.signal
12393
12502
  }) !== 0 && !backfillAbortController.signal.aborted) logger.warn("⚠️ aggregateBackfill on schema update failed in dev (continuing without blocking).");
@@ -12415,6 +12524,7 @@ const handleDevCommand = async (argv, deps) => {
12415
12524
  await authEnvSyncPromise;
12416
12525
  await syncEnvFn({
12417
12526
  authSyncMode: "auto",
12527
+ commandEnv: effectiveConvexCommandEnv ?? void 0,
12418
12528
  force: true,
12419
12529
  sharedDir,
12420
12530
  silent: true,
@@ -12442,6 +12552,7 @@ const handleDevCommand = async (argv, deps) => {
12442
12552
  runTask: () => runMigrationFlow({
12443
12553
  execaFn,
12444
12554
  backendAdapter,
12555
+ env: effectiveConvexCommandEnv ?? void 0,
12445
12556
  migrationConfig: devMigrationConfig,
12446
12557
  targetArgs,
12447
12558
  signal: backfillAbortController.signal,
@@ -12464,6 +12575,7 @@ const handleDevCommand = async (argv, deps) => {
12464
12575
  execaFn,
12465
12576
  backendAdapter,
12466
12577
  backfillConfig: devBackfillConfig,
12578
+ env: effectiveConvexCommandEnv ?? void 0,
12467
12579
  mode: "resume",
12468
12580
  targetArgs,
12469
12581
  signal: backfillAbortController.signal,
@@ -1,4 +1,4 @@
1
- import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-DdjN63Io.js";
1
+ import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-Dw3EVdi6.js";
2
2
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-vzRKjBJC.js";
3
3
  import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CFZqIvD7.js";
4
4
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
@@ -3717,19 +3717,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3717
3717
  readonly aggregate_bucket: ConvexTableWithColumns<{
3718
3718
  name: "aggregate_bucket";
3719
3719
  columns: {
3720
- count: ConvexNumberBuilderInitial<""> & {
3721
- _: {
3722
- notNull: true;
3723
- };
3724
- } & {
3725
- _: {
3726
- tableName: "aggregate_bucket";
3727
- };
3728
- } & {
3729
- _: {
3730
- fieldName: "count";
3731
- };
3732
- };
3733
3720
  tableKey: ConvexTextBuilderInitial<""> & {
3734
3721
  _: {
3735
3722
  notNull: true;
@@ -3799,6 +3786,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3799
3786
  fieldName: "keyParts";
3800
3787
  };
3801
3788
  };
3789
+ count: ConvexNumberBuilderInitial<""> & {
3790
+ _: {
3791
+ notNull: true;
3792
+ };
3793
+ } & {
3794
+ _: {
3795
+ tableName: "aggregate_bucket";
3796
+ };
3797
+ } & {
3798
+ _: {
3799
+ fieldName: "count";
3800
+ };
3801
+ };
3802
3802
  sumValues: (NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VRecord<Record<string, any>, convex_values0.VString<string, "required">, convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>, "required", string>>, Record<string, number>>> | NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>>, Record<string, number>>>) & {
3803
3803
  _: {
3804
3804
  tableName: "aggregate_bucket";
@@ -4009,7 +4009,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4009
4009
  fieldName: "value";
4010
4010
  };
4011
4011
  };
4012
- count: ConvexNumberBuilderInitial<""> & {
4012
+ tableKey: ConvexTextBuilderInitial<""> & {
4013
4013
  _: {
4014
4014
  notNull: true;
4015
4015
  };
@@ -4019,10 +4019,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4019
4019
  };
4020
4020
  } & {
4021
4021
  _: {
4022
- fieldName: "count";
4022
+ fieldName: "tableKey";
4023
4023
  };
4024
4024
  };
4025
- tableKey: ConvexTextBuilderInitial<""> & {
4025
+ indexName: ConvexTextBuilderInitial<""> & {
4026
4026
  _: {
4027
4027
  notNull: true;
4028
4028
  };
@@ -4032,10 +4032,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4032
4032
  };
4033
4033
  } & {
4034
4034
  _: {
4035
- fieldName: "tableKey";
4035
+ fieldName: "indexName";
4036
4036
  };
4037
4037
  };
4038
- indexName: ConvexTextBuilderInitial<""> & {
4038
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4039
4039
  _: {
4040
4040
  notNull: true;
4041
4041
  };
@@ -4045,10 +4045,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4045
4045
  };
4046
4046
  } & {
4047
4047
  _: {
4048
- fieldName: "indexName";
4048
+ fieldName: "updatedAt";
4049
4049
  };
4050
4050
  };
4051
- updatedAt: ConvexNumberBuilderInitial<""> & {
4051
+ keyHash: ConvexTextBuilderInitial<""> & {
4052
4052
  _: {
4053
4053
  notNull: true;
4054
4054
  };
@@ -4058,10 +4058,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4058
4058
  };
4059
4059
  } & {
4060
4060
  _: {
4061
- fieldName: "updatedAt";
4061
+ fieldName: "keyHash";
4062
4062
  };
4063
4063
  };
4064
- keyHash: ConvexTextBuilderInitial<""> & {
4064
+ count: ConvexNumberBuilderInitial<""> & {
4065
4065
  _: {
4066
4066
  notNull: true;
4067
4067
  };
@@ -4071,7 +4071,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4071
4071
  };
4072
4072
  } & {
4073
4073
  _: {
4074
- fieldName: "keyHash";
4074
+ fieldName: "count";
4075
4075
  };
4076
4076
  };
4077
4077
  fieldName: ConvexTextBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.12.8",
3
+ "version": "0.12.9",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",