kitcn 0.12.20 → 0.12.22

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.
@@ -8,13 +8,16 @@ import { getToken } from "@convex-dev/better-auth/utils";
8
8
  * Next.js + Better Auth wrapper for Convex caller factory.
9
9
  * Uses @convex-dev/better-auth for token management.
10
10
  */
11
- const handler = (request, siteUrl) => {
11
+ const handler = async (request, siteUrl) => {
12
12
  const requestUrl = new URL(request.url);
13
13
  const nextUrl = `${siteUrl}${requestUrl.pathname}${requestUrl.search}`;
14
- const newRequest = new Request(nextUrl, request);
15
- newRequest.headers.set("accept-encoding", "application/json");
16
- newRequest.headers.set("host", new URL(siteUrl).host);
17
- return fetch(newRequest, {
14
+ const headers = new Headers(request.headers);
15
+ headers.set("accept-encoding", "application/json");
16
+ headers.set("host", new URL(siteUrl).host);
17
+ const body = request.method !== "GET" && request.method !== "HEAD" ? await request.arrayBuffer() : void 0;
18
+ return fetch(nextUrl, {
19
+ body,
20
+ headers,
18
21
  method: request.method,
19
22
  redirect: "manual"
20
23
  });
@@ -14353,6 +14353,9 @@ function buildCodegenBootstrapArgs(targetArgs) {
14353
14353
  function didConvexInitCreateConfiguration(output) {
14354
14354
  return CONVEX_INIT_CREATED_CONFIG_RE.test(output);
14355
14355
  }
14356
+ function isLocalBackendUpgradePrompt(output) {
14357
+ return output.includes("This deployment is using an older version of the Convex backend. Upgrade now?");
14358
+ }
14356
14359
  async function runConvexInitIfNeeded(params) {
14357
14360
  if (params.backendAdapter.publicName !== "convex") return {
14358
14361
  created: false,
@@ -14360,12 +14363,9 @@ async function runConvexInitIfNeeded(params) {
14360
14363
  stdout: "",
14361
14364
  stderr: ""
14362
14365
  };
14363
- const agentModeOverride = params.yes && getAggregateBackfillDeploymentKey(params.targetArgs ?? [], process.cwd(), params.env) === "local" ? "anonymous" : params.env?.CONVEX_AGENT_MODE;
14364
- const result = normalizeConvexCommandResult(await params.execaFn(params.backendAdapter.command, [
14365
- ...params.backendAdapter.argsPrefix,
14366
- "init",
14367
- ...params.targetArgs ?? []
14368
- ], {
14366
+ const shouldUseLocalDevPreflight = getAggregateBackfillDeploymentKey(params.targetArgs ?? [], process.cwd(), params.env) === "local";
14367
+ const agentModeOverride = params.yes && shouldUseLocalDevPreflight ? "anonymous" : params.env?.CONVEX_AGENT_MODE;
14368
+ const runCommand = async (commandArgs) => normalizeConvexCommandResult(await params.execaFn(params.backendAdapter.command, commandArgs, {
14369
14369
  cwd: process.cwd(),
14370
14370
  env: createBackendCommandEnv({
14371
14371
  ...params.env,
@@ -14374,6 +14374,24 @@ async function runConvexInitIfNeeded(params) {
14374
14374
  reject: false,
14375
14375
  stdio: "pipe"
14376
14376
  }));
14377
+ let result = await runCommand([
14378
+ ...params.backendAdapter.argsPrefix,
14379
+ "init",
14380
+ ...params.targetArgs ?? []
14381
+ ]);
14382
+ if (shouldUseLocalDevPreflight && result.exitCode !== 0 && isLocalBackendUpgradePrompt(`${result.stdout}\n${result.stderr}`)) result = await runCommand([
14383
+ ...params.backendAdapter.argsPrefix,
14384
+ "dev",
14385
+ "--local",
14386
+ "--once",
14387
+ "--skip-push",
14388
+ "--local-force-upgrade",
14389
+ "--typecheck",
14390
+ "disable",
14391
+ "--codegen",
14392
+ "disable",
14393
+ ...params.targetArgs ?? []
14394
+ ]);
14377
14395
  if (params.echoOutput !== false || result.exitCode !== 0) writeConvexCommandOutput(result);
14378
14396
  return {
14379
14397
  created: didConvexInitCreateConfiguration(`${result.stdout}\n${result.stderr}`),
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as resolveAddTemplateDefaults, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, Et as highlighter, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as createSpinner, K as withLocalCodegenEnv, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as promptForScaffoldTemplateSelection, R as runBackendFunction, S as isEntryPoint, St as stripConvexCommandNoise, T as parseBackendRunJson, Tt as logger, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as filterScaffoldTemplatePathMap, Y as collectPluginScaffoldTemplates, Z as promptForPluginSelection, _ as formatInfoOutput, _t as applyPluginDependencyInstall, a as cleanup, at as getSupportedPluginKeys, b as hasRemoteConvexDeploymentEnv, bt as resolveAuthEnvState, c as createCommandEnv, ct as resolvePluginScaffoldRoots, d as extractBackfillCliOptions, dt as getPluginLockfilePath, et as resolvePluginPreset, f as extractConcaveRunTargetArgs, ft as getSchemaFilePath, g as formatDocsOutput, gt as applyPlanningDependencyInstall, h as extractResetCliOptions, ht as applyDependencyHintsInstall, i as buildInitializationPlan, it as getPluginCatalogEntry, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as assertSchemaFileExists, m as extractMigrationDownOptions, mt as resolveSchemaInstalledPlugins, n as applyPluginInstallPlanFiles, nt as resolveTemplateSelectionSource, o as createBackendAdapter, ot as isSupportedPluginKey, p as extractMigrationCliOptions, pt as readPluginLockfile, q as withWorkingDirectory, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplatesByIdOrThrow, s as createBackendCommandEnv, st as buildPluginInstallPlan, t as applyDependencyInstallPlan, tt as resolvePresetScaffoldTemplates, u as extractBackendRunTargetArgs, ut as collectInstalledPluginKeys, v as getAggregateBackfillDeploymentKey, vt as inspectPluginDependencyInstall, w as parseArgs, x as isConvexDevPreRunConflictFlag, xt as serializeEnvValue, y as getDevAggregateBackfillStatePath, yt as resolveProjectScaffoldContext, z as runConfiguredCodegen } from "./backend-core-C0uwGXLx.mjs";
2
+ import { $ as resolveAddTemplateDefaults, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, Et as highlighter, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as createSpinner, K as withLocalCodegenEnv, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as promptForScaffoldTemplateSelection, R as runBackendFunction, S as isEntryPoint, St as stripConvexCommandNoise, T as parseBackendRunJson, Tt as logger, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as filterScaffoldTemplatePathMap, Y as collectPluginScaffoldTemplates, Z as promptForPluginSelection, _ as formatInfoOutput, _t as applyPluginDependencyInstall, a as cleanup, at as getSupportedPluginKeys, b as hasRemoteConvexDeploymentEnv, bt as resolveAuthEnvState, c as createCommandEnv, ct as resolvePluginScaffoldRoots, d as extractBackfillCliOptions, dt as getPluginLockfilePath, et as resolvePluginPreset, f as extractConcaveRunTargetArgs, ft as getSchemaFilePath, g as formatDocsOutput, gt as applyPlanningDependencyInstall, h as extractResetCliOptions, ht as applyDependencyHintsInstall, i as buildInitializationPlan, it as getPluginCatalogEntry, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as assertSchemaFileExists, m as extractMigrationDownOptions, mt as resolveSchemaInstalledPlugins, n as applyPluginInstallPlanFiles, nt as resolveTemplateSelectionSource, o as createBackendAdapter, ot as isSupportedPluginKey, p as extractMigrationCliOptions, pt as readPluginLockfile, q as withWorkingDirectory, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplatesByIdOrThrow, s as createBackendCommandEnv, st as buildPluginInstallPlan, t as applyDependencyInstallPlan, tt as resolvePresetScaffoldTemplates, u as extractBackendRunTargetArgs, ut as collectInstalledPluginKeys, v as getAggregateBackfillDeploymentKey, vt as inspectPluginDependencyInstall, w as parseArgs, x as isConvexDevPreRunConflictFlag, xt as serializeEnvValue, y as getDevAggregateBackfillStatePath, yt as resolveProjectScaffoldContext, z as runConfiguredCodegen } from "./backend-core-DBBEoGeA.mjs";
3
3
  import fs, { existsSync, readFileSync } from "node:fs";
4
4
  import path, { delimiter, dirname, join, relative, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
package/dist/watcher.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { A as resolveConfiguredBackend, Ct as generateMeta, K as withLocalCodegenEnv, P as resolveRunDeps, Tt as logger, wt as getConvexConfig } from "./backend-core-C0uwGXLx.mjs";
2
+ import { A as resolveConfiguredBackend, Ct as generateMeta, K as withLocalCodegenEnv, P as resolveRunDeps, Tt as logger, wt as getConvexConfig } from "./backend-core-DBBEoGeA.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.12.20",
3
+ "version": "0.12.22",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -203,13 +203,16 @@ Local Convex:
203
203
  2. While `kitcn dev` is running on backend `convex`, later edits to `convex/.env` auto-sync.
204
204
  3. For the normal local path, `SITE_URL` should stay on `http://localhost:3000`.
205
205
 
206
- Remote / repair:
206
+ Convex remote / repair:
207
207
  1. Use `npx kitcn env push` when the target deployment is already active.
208
208
  2. Use `npx kitcn env push --prod` for production sync.
209
- 3. Use `npx kitcn auth jwks` when you need a manual static `JWKS` payload, including backend `concave`.
209
+ 3. Use `npx kitcn env push --rotate` when you want fresh keys plus fresh `JWKS`.
210
+ 4. `kitcn env push` writes deployment env for you. No manual copy step.
210
211
 
211
- Key rotation: `npx kitcn env push --rotate` (invalidates all tokens).
212
- Manual rotation/export: `npx kitcn auth jwks --rotate`.
212
+ Concave manual lane:
213
+ 1. Use `npx kitcn --backend concave auth jwks` when you need a manual static `JWKS` payload.
214
+ 2. Use `npx kitcn --backend concave auth jwks --rotate` when you need rotation plus export.
215
+ 3. `kitcn auth jwks` only prints `JWKS=...`. Save that value into env yourself.
213
216
 
214
217
  ---
215
218
 
@@ -256,6 +256,8 @@ GOOGLE_CLIENT_ID=...
256
256
  GOOGLE_CLIENT_SECRET=...
257
257
  ```
258
258
 
259
+ ### Convex lane
260
+
259
261
  Local Convex:
260
262
 
261
263
  ```bash
@@ -277,25 +279,33 @@ Use this to sync static `JWKS` onto the target deployment too.
277
279
  ```bash
278
280
  bunx kitcn env push --prod
279
281
  bunx kitcn env push --rotate
280
-
281
- # Manual static JWKS payload, including backend concave
282
- bunx kitcn auth jwks
283
- bunx kitcn auth jwks --rotate
284
282
  ```
285
283
 
286
284
  Use `--prod` for production and `--rotate` when you want fresh keys plus fresh
287
- `JWKS`. `kitcn auth jwks` prints a manual `JWKS=...` line when you need to set
288
- the env value yourself instead of using `env push`. See `/docs/cli/backend#env`
289
- and `/docs/cli/backend#auth` for the full command surface.
285
+ `JWKS`.
286
+
287
+ `kitcn env push` writes the target deployment env for you. No manual copy step.
288
+
289
+ ### Concave lane
290
290
 
291
- Rotate later:
291
+ Concave has no `kitcn env` wrapper. Export a manual `JWKS=...` line from the
292
+ target backend, then set that env manually:
292
293
 
293
294
  ```bash
294
- bunx kitcn env push --rotate
295
+ bunx kitcn --backend concave auth jwks --url http://localhost:3210
296
+ bunx kitcn --backend concave auth jwks --rotate --url http://localhost:3210
295
297
  ```
296
298
 
299
+ Use `--url`, `--port`, or `--component` to target the right Concave runtime.
300
+ See `/docs/cli/backend#env` and `/docs/cli/backend#auth` for the full command
301
+ surface.
302
+
303
+ `kitcn auth jwks` only prints `JWKS=...`. Save that value into env yourself.
304
+
297
305
  ### 6.7 Production bootstrap notes
298
306
 
307
+ #### Convex lane
308
+
299
309
  First prod deploy requires JWKS initialization:
300
310
 
301
311
  ```bash
@@ -303,6 +313,17 @@ bunx convex deploy --prod
303
313
  bunx kitcn env push --prod
304
314
  ```
305
315
 
316
+ #### Concave lane
317
+
318
+ Concave has no `kitcn env push --prod` flow. Export a static JWKS payload from
319
+ the deployed backend, then set the printed `JWKS=...` line manually:
320
+
321
+ ```bash
322
+ bunx kitcn --backend concave auth jwks --url https://your-concave-backend.example.com
323
+ ```
324
+
325
+ Again: printed payload only. You still need to set the env manually.
326
+
306
327
  ### 6.9 Upgrade `convex/lib/crpc.ts` to auth-aware builders (only after Section 11.2 passes)
307
328
 
308
329
  After non-auth baseline is green, replace `convex/lib/crpc.ts` with this auth-aware variant:
@@ -602,6 +602,8 @@ app owns an `init.ts` preflight.
602
602
 
603
603
  CLI commands:
604
604
 
605
+ Convex lane:
606
+
605
607
  ```bash
606
608
  bunx kitcn dev
607
609
  # deterministic one-shot local runtime proof:
@@ -623,11 +625,19 @@ bunx kitcn aggregate backfill --prod
623
625
  bunx kitcn analyze
624
626
  ```
625
627
 
628
+ Concave lane:
629
+
630
+ ```bash
631
+ bunx kitcn --backend concave auth jwks --url http://localhost:3210
632
+ bunx kitcn --backend concave auth jwks --rotate --url http://localhost:3210
633
+ ```
634
+
626
635
  On backend `convex`, `kitcn dev` watches `convex/.env` during a local
627
636
  dev session and auto-pushes later edits. Keep `env push` for `--prod`,
628
- `--rotate`, or explicit repair against an already active deployment. Use
629
- `auth jwks` when you need a manual static `JWKS` payload, especially on backend
630
- `concave`.
637
+ `--rotate`, or explicit repair against an already active deployment.
638
+
639
+ On backend `concave`, `kitcn env` is not the right seam. Use `auth jwks`
640
+ for manual static `JWKS` export instead.
631
641
 
632
642
  ### 11.2 Phase A gate: non-auth baseline (required before auth work)
633
643
 
@@ -3,6 +3,10 @@
3
3
  CLI-first flow: scaffold the app, run `kitcn add auth --yes`, then treat the
4
4
  files below as the generated reference output. They are not a separate manual
5
5
  install path.
6
+
7
+ After changing plugins or auth fields in `<functionsDir>/auth.ts`, refresh
8
+ auth-owned schema blocks with `bunx kitcn add auth --schema --yes`. Keep
9
+ `bunx kitcn dev` running as the local Convex + codegen loop.
6
10
  ### 8.B.1 Auth client + auth server helpers
7
11
 
8
12
  **Create:** `src/lib/convex/auth-client.ts`