kitcn 0.12.27 → 0.13.1

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.
Files changed (73) hide show
  1. package/dist/aggregate/index.d.ts +1 -1
  2. package/dist/aggregate/index.js +1 -1
  3. package/dist/auth/client/index.d.ts +312 -4
  4. package/dist/auth/client/index.js +17 -5
  5. package/dist/auth/config/index.d.ts +1 -1
  6. package/dist/auth/generated/index.d.ts +1 -1
  7. package/dist/auth/generated/index.js +1 -1
  8. package/dist/auth/http/index.d.ts +12 -9
  9. package/dist/auth/http/index.js +35 -6
  10. package/dist/auth/index.d.ts +292 -8
  11. package/dist/auth/index.js +29 -23
  12. package/dist/auth/nextjs/index.d.ts +4 -3
  13. package/dist/auth/nextjs/index.js +9 -4
  14. package/dist/auth/start/index.d.ts +13 -3
  15. package/dist/auth/start/index.js +97 -8
  16. package/dist/{backend-core-DqCCa0nr.mjs → backend-core-yq-eWLRJ.mjs} +140 -54
  17. package/dist/{builder-Cb6gloDB.js → builder-DBgto1yn.js} +4 -3
  18. package/dist/{caller-factory-cTXNvYdz.js → caller-factory-NEfgD5E0.js} +3 -3
  19. package/dist/cli.mjs +26 -26
  20. package/dist/convex-plugin-C3N9BB-J.js +275 -0
  21. package/dist/convex-plugin-tWTDqoKJ.mjs +276 -0
  22. package/dist/{create-schema-orm-DOyiNDCx.js → create-schema-orm-B3f2Kc8O.js} +1 -1
  23. package/dist/crpc/index.d.ts +2 -2
  24. package/dist/crpc/index.js +3 -3
  25. package/dist/{customFunctions-C0voKmtx.js → customFunctions-DxEEO4Dq.js} +2 -1
  26. package/dist/{generated-contract-disabled-21YxPk5W.d.ts → generated-contract-disabled-C_-KWRfT.d.ts} +4 -2
  27. package/dist/{http-types-BLFA9zS7.d.ts → http-types-zsMHb_QN.d.ts} +2 -2
  28. package/dist/{middleware-DkIhQXwg.js → middleware-Bg-PdtrI.js} +1 -1
  29. package/dist/{middleware-nS_qXecO.d.ts → middleware-DrtexzF3.d.ts} +1 -1
  30. package/dist/orm/index.d.ts +3 -3
  31. package/dist/orm/index.js +3 -3
  32. package/dist/plugins/index.d.ts +1 -1
  33. package/dist/plugins/index.js +1 -1
  34. package/dist/{procedure-caller-AjLfkHyF.js → procedure-caller-DplSC7Us.js} +2 -2
  35. package/dist/{procedure-name-D-fDCBlo.d.ts → procedure-name-BCRBr6Po.d.ts} +3 -3
  36. package/dist/ratelimit/index.d.ts +2 -2
  37. package/dist/ratelimit/index.js +3 -3
  38. package/dist/react/index.d.ts +18 -14
  39. package/dist/react/index.js +14 -27
  40. package/dist/rsc/index.d.ts +4 -4
  41. package/dist/rsc/index.js +4 -4
  42. package/dist/{runtime-CtvJPkur.js → runtime-i6t-HoZn.js} +1 -1
  43. package/dist/server/index.d.ts +4 -4
  44. package/dist/server/index.js +4 -4
  45. package/dist/solid/index.d.ts +300 -4
  46. package/dist/token-B9Bjcqug.d.ts +13 -0
  47. package/dist/token-tpipF-7y.js +47 -0
  48. package/dist/{types-C6pQrnzD.d.ts → types-YHpe0rsb.d.ts} +1 -1
  49. package/dist/upstream-BR6sBLg3.js +84 -0
  50. package/dist/upstream-BUCdbLok.mjs +26 -0
  51. package/dist/{validators-B7oIJCAp.js → validators-C7LelqTN.js} +2 -84
  52. package/dist/watcher.mjs +1 -1
  53. package/dist/{where-clause-compiler-DdjN63Io.d.ts → where-clause-compiler-TMppDl9g.d.ts} +51 -51
  54. package/package.json +5 -4
  55. package/skills/convex/references/features/auth.md +20 -0
  56. package/skills/convex/references/features/orm.md +9 -0
  57. package/skills/convex/references/setup/auth.md +2 -0
  58. package/skills/convex/references/setup/index.md +5 -5
  59. package/skills/convex/references/setup/server.md +1 -1
  60. /package/dist/{api-entry-BUAh_K4k.js → api-entry-N3nBOlI2.js} +0 -0
  61. /package/dist/{context-utils-BvWW0Ilq.d.ts → context-utils-OMkMGhBk.d.ts} +0 -0
  62. /package/dist/{create-schema-odyF4kCy.js → create-schema-BXrKE2YY.js} +0 -0
  63. /package/dist/{error-BZEnI7Sq.js → error-Bvo7YEhk.js} +0 -0
  64. /package/dist/{generated-contract-disabled-Cih4eITO.js → generated-contract-disabled-BXaz7JCE.js} +0 -0
  65. /package/dist/{meta-utils-0Pu0Nrap.js → meta-utils-D9K4fICl.js} +0 -0
  66. /package/dist/{query-context-CFZqIvD7.d.ts → query-context-CNo9ffvI.d.ts} +0 -0
  67. /package/dist/{query-context-B8o6-8kC.js → query-context-ydn9kb6P.js} +0 -0
  68. /package/dist/{query-options-Dw7cOyXl.js → query-options-C96zLANM.js} +0 -0
  69. /package/dist/{transformer-DtDhR3Lc.js → transformer-C6pGVHqx.js} +0 -0
  70. /package/dist/{types-BiJE7qxR.d.ts → types-BCl8gfGy.d.ts} +0 -0
  71. /package/dist/{types-a-RHmrDZ.d.ts → types-CnTpHR1F.d.ts} +0 -0
  72. /package/dist/{types-BTb_4BaU.d.ts → types-DF2cg_w0.d.ts} +0 -0
  73. /package/dist/{validators-vzRKjBJC.d.ts → validators-BhsByJeg.d.ts} +0 -0
@@ -1,8 +1,31 @@
1
- import { convexBetterAuthReactStart as convexBetterAuthReactStart$1 } from "@convex-dev/better-auth/react-start";
2
-
3
- export * from "@convex-dev/better-auth/react-start"
1
+ import { t as getToken } from "../../token-tpipF-7y.js";
2
+ import { stripIndent } from "common-tags";
3
+ import { ConvexHttpClient } from "convex/browser";
4
+ import React from "react";
4
5
 
5
6
  //#region src/auth-start/index.ts
7
+ const fallbackCache = (fn) => fn;
8
+ const cache = React.cache ?? fallbackCache;
9
+ const TANSTACK_REACT_START_SERVER = "@tanstack/react-start/server";
10
+ const TRAILING_COLON_RE = /:$/;
11
+ function setupClient(options) {
12
+ const client = new ConvexHttpClient(options.convexUrl);
13
+ if (options.token !== void 0) client.setAuth(options.token);
14
+ client.setFetchOptions?.({ cache: "no-store" });
15
+ return client;
16
+ }
17
+ const parseConvexSiteUrl = (url) => {
18
+ if (!url) throw new Error(stripIndent`
19
+ CONVEX_SITE_URL is not set.
20
+ This is automatically set in the Convex backend, but must be set in the TanStack Start environment.
21
+ For local development, this can be set in the .env.local file.
22
+ `);
23
+ if (url.endsWith(".convex.cloud")) throw new Error(stripIndent`
24
+ CONVEX_SITE_URL should be set to your Convex Site URL, which ends in .convex.site.
25
+ Currently set to ${url}.
26
+ `);
27
+ return url;
28
+ };
6
29
  const appendSetCookieHeaders = (target, source) => {
7
30
  const getSetCookie = source.getSetCookie;
8
31
  if (typeof getSetCookie === "function") {
@@ -26,13 +49,79 @@ const cloneAuthHandlerResponse = (response) => {
26
49
  statusText: response.statusText
27
50
  });
28
51
  };
29
- const convexBetterAuthReactStart = ((...args) => {
30
- const auth = convexBetterAuthReactStart$1(...args);
52
+ const handler = (request, opts) => {
53
+ const requestUrl = new URL(request.url);
54
+ const nextUrl = `${opts.convexSiteUrl}${requestUrl.pathname}${requestUrl.search}`;
55
+ const headers = new Headers(request.headers);
56
+ const proto = requestUrl.protocol.replace(TRAILING_COLON_RE, "");
57
+ headers.set("accept-encoding", "application/json");
58
+ headers.set("host", new URL(opts.convexSiteUrl).host);
59
+ headers.set("x-forwarded-host", requestUrl.host);
60
+ headers.set("x-forwarded-proto", proto);
61
+ headers.set("x-better-auth-forwarded-host", requestUrl.host);
62
+ headers.set("x-better-auth-forwarded-proto", proto);
63
+ return fetch(nextUrl, {
64
+ body: request.method !== "GET" && request.method !== "HEAD" ? request.body : void 0,
65
+ duplex: "half",
66
+ headers,
67
+ method: request.method,
68
+ redirect: "manual"
69
+ });
70
+ };
71
+ const convexBetterAuthReactStart = (opts) => {
72
+ const siteUrl = parseConvexSiteUrl(opts.convexSiteUrl);
73
+ const cachedGetToken = cache(async (opts) => {
74
+ const { getRequestHeaders } = await import(TANSTACK_REACT_START_SERVER);
75
+ const headers = getRequestHeaders();
76
+ const mutableHeaders = new Headers(headers);
77
+ mutableHeaders.delete("content-length");
78
+ mutableHeaders.delete("transfer-encoding");
79
+ mutableHeaders.set("accept-encoding", "identity");
80
+ return getToken(siteUrl, mutableHeaders, opts);
81
+ });
82
+ const callWithToken = async (fn) => {
83
+ const token = await cachedGetToken(opts) ?? {};
84
+ try {
85
+ return await fn(token?.token);
86
+ } catch (error) {
87
+ if (!opts?.jwtCache?.enabled || token.isFresh || !opts.jwtCache?.isAuthError(error)) throw error;
88
+ return await fn((await cachedGetToken({
89
+ ...opts,
90
+ forceRefresh: true
91
+ })).token);
92
+ }
93
+ };
31
94
  return {
32
- ...auth,
33
- handler: async (request) => cloneAuthHandlerResponse(await auth.handler(request))
95
+ getToken: async () => {
96
+ return (await cachedGetToken(opts)).token;
97
+ },
98
+ handler: async (request) => cloneAuthHandlerResponse(await handler(request, opts)),
99
+ fetchAuthQuery: async (query, ...args) => {
100
+ return callWithToken((token) => {
101
+ return setupClient({
102
+ ...opts,
103
+ token
104
+ }).query(query, ...args);
105
+ });
106
+ },
107
+ fetchAuthMutation: async (mutation, ...args) => {
108
+ return callWithToken((token) => {
109
+ return setupClient({
110
+ ...opts,
111
+ token
112
+ }).mutation(mutation, ...args);
113
+ });
114
+ },
115
+ fetchAuthAction: async (action, ...args) => {
116
+ return callWithToken((token) => {
117
+ return setupClient({
118
+ ...opts,
119
+ token
120
+ }).action(action, ...args);
121
+ });
122
+ }
34
123
  };
35
- });
124
+ };
36
125
 
37
126
  //#endregion
38
127
  export { convexBetterAuthReactStart };
@@ -5662,6 +5662,7 @@ const CONVEX_OUTPUT_NOISE_LINES = [
5662
5662
  /^Changelog: https:\/\/github\.com\/get-convex\/convex-js\/blob\/main\/CHANGELOG\.md#changelog$/
5663
5663
  ];
5664
5664
  const CONVEX_OUTPUT_LINE_SPLIT_RE = /\r?\n/;
5665
+ const REAL_CONVEX_CLI_PATH = join(dirname(createRequire(import.meta.url).resolve("convex/package.json")), "bin/main.js");
5665
5666
  const CLEARED_CONVEX_ENV = {
5666
5667
  CONVEX_DEPLOYMENT: void 0,
5667
5668
  CONVEX_DEPLOY_KEY: void 0,
@@ -5683,16 +5684,15 @@ const formatConvexCommandFailure = (args, result) => {
5683
5684
  return output.length > 0 ? `convex ${args.join(" ")} failed.\n${output}` : `convex ${args.join(" ")} failed.`;
5684
5685
  };
5685
5686
  const runLocalConvexCommand = async (args, options) => {
5686
- return normalizeConvexCommandResult(await execa("convex", args, {
5687
+ return normalizeConvexCommandResult(await execa("node", [REAL_CONVEX_CLI_PATH, ...args], {
5687
5688
  cwd: options.cwd,
5688
5689
  env: {
5689
5690
  ...process.env,
5690
5691
  ...CLEARED_CONVEX_ENV,
5691
5692
  ...options.env
5692
5693
  },
5693
- localDir: options.cwd,
5694
- preferLocal: true,
5695
- reject: false
5694
+ reject: false,
5695
+ stdio: "pipe"
5696
5696
  }));
5697
5697
  };
5698
5698
 
@@ -6159,14 +6159,18 @@ function resolveProjectScaffoldContext(params = {}) {
6159
6159
  //#endregion
6160
6160
  //#region src/cli/supported-dependencies.ts
6161
6161
  const EXACT_VERSION_RE = /^(\d+)\.(\d+)\.\d+$/;
6162
- const SUPPORTED_CONVEX_VERSION = "1.33.0";
6163
- const SUPPORTED_BETTER_AUTH_VERSION = "1.5.3";
6162
+ const VERSION_IN_SPEC_RE = /(\d+)\.(\d+)(?:\.\d+)?/;
6163
+ const PLAIN_VERSION_SPEC_RE = /^[\^~]?v?\d+\.\d+(?:\.\d+)?$/;
6164
+ const UPPER_BOUND_RE = /(?:^|\s)<={0,1}\s*v?(\d+)\.(\d+)(?:\.\d+)?/g;
6165
+ const SUPPORTED_CONVEX_VERSION = "1.35.1";
6166
+ const SUPPORTED_BETTER_AUTH_VERSION = "1.6.5";
6164
6167
  const SUPPORTED_HONO_VERSION = "4.12.9";
6165
6168
  const SUPPORTED_OPENTELEMETRY_API_VERSION = "1.9.0";
6166
6169
  const SUPPORTED_TANSTACK_REACT_QUERY_VERSION = "5.95.2";
6167
6170
  const SUPPORTED_ZOD_VERSION = "4.3.6";
6168
6171
  const KITCN_INSTALL_SPEC_ENV = "KITCN_INSTALL_SPEC";
6169
6172
  const KITCN_RESEND_INSTALL_SPEC_ENV = "KITCN_RESEND_INSTALL_SPEC";
6173
+ let ownVersion;
6170
6174
  function getMinimumVersionRange(version) {
6171
6175
  const match = EXACT_VERSION_RE.exec(version);
6172
6176
  if (!match) throw new Error(`Unsupported exact version "${version}". Expected x.y.z format.`);
@@ -6189,10 +6193,37 @@ const LOCAL_INSTALL_SPEC_ENV_BY_PACKAGE_NAME = {
6189
6193
  "@kitcn/resend": KITCN_RESEND_INSTALL_SPEC_ENV
6190
6194
  };
6191
6195
  function resolveSupportedDependencyInstallSpec(spec, env = process.env) {
6196
+ if (getPackageNameFromInstallSpec(spec) === "kitcn") return resolveScaffoldInstallSpec(env);
6192
6197
  const envKey = LOCAL_INSTALL_SPEC_ENV_BY_PACKAGE_NAME[getPackageNameFromInstallSpec(spec)];
6193
6198
  const override = envKey ? env[envKey]?.trim() : void 0;
6194
6199
  return override && override.length > 0 ? override : spec;
6195
6200
  }
6201
+ function readOwnVersion() {
6202
+ if (ownVersion !== void 0) return ownVersion ?? void 0;
6203
+ let currentDir = dirname(fileURLToPath(import.meta.url));
6204
+ while (true) {
6205
+ const packageJsonPath = join(currentDir, "package.json");
6206
+ if (fs.existsSync(packageJsonPath)) {
6207
+ const parsed = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
6208
+ if (parsed.name === "kitcn") {
6209
+ ownVersion = parsed.version ?? null;
6210
+ return ownVersion ?? void 0;
6211
+ }
6212
+ }
6213
+ const parentDir = dirname(currentDir);
6214
+ if (parentDir === currentDir) {
6215
+ ownVersion = null;
6216
+ return;
6217
+ }
6218
+ currentDir = parentDir;
6219
+ }
6220
+ }
6221
+ function resolveScaffoldInstallSpec(env = process.env) {
6222
+ const override = env[KITCN_INSTALL_SPEC_ENV]?.trim();
6223
+ if (override) return override;
6224
+ const version = readOwnVersion();
6225
+ return version ? `kitcn@${version}` : "kitcn";
6226
+ }
6196
6227
  const SUPPORTED_DEPENDENCY_VERSIONS = {
6197
6228
  convex: {
6198
6229
  exact: SUPPORTED_CONVEX_VERSION,
@@ -6221,6 +6252,73 @@ const BASELINE_DEPENDENCY_INSTALL_SPECS = [
6221
6252
  PINNED_HONO_INSTALL_SPEC
6222
6253
  ];
6223
6254
  const INIT_TEMPLATE_DEPENDENCY_INSTALL_SPECS = ["superjson"];
6255
+ const DEPENDENCY_SECTIONS = [
6256
+ "dependencies",
6257
+ "devDependencies",
6258
+ "peerDependencies",
6259
+ "optionalDependencies"
6260
+ ];
6261
+ function findNearestPackageJsonPath$2(cwd) {
6262
+ let currentDir = cwd;
6263
+ while (true) {
6264
+ const packageJsonPath = join(currentDir, "package.json");
6265
+ if (fs.existsSync(packageJsonPath)) return packageJsonPath;
6266
+ const parentDir = dirname(currentDir);
6267
+ if (parentDir === currentDir) return;
6268
+ currentDir = parentDir;
6269
+ }
6270
+ }
6271
+ function readDependencyVersion(packageJson, packageName) {
6272
+ for (const section of DEPENDENCY_SECTIONS) {
6273
+ const version = packageJson[section]?.[packageName];
6274
+ if (version) return version;
6275
+ }
6276
+ }
6277
+ function readInstalledDependencyVersion(packageJsonPath, packageName) {
6278
+ const installedPackageJsonPath = join(dirname(packageJsonPath), "node_modules", ...packageName.split("/"), "package.json");
6279
+ if (!fs.existsSync(installedPackageJsonPath)) return;
6280
+ return JSON.parse(fs.readFileSync(installedPackageJsonPath, "utf8")).version;
6281
+ }
6282
+ function compareMajorMinor(aMajor, aMinor, bMajor, bMinor) {
6283
+ if (aMajor !== bMajor) return aMajor - bMajor;
6284
+ return aMinor - bMinor;
6285
+ }
6286
+ function isConcreteVersionSpecBelowMinimum(spec, minimum) {
6287
+ const specMatch = VERSION_IN_SPEC_RE.exec(spec);
6288
+ const minimumMatch = VERSION_IN_SPEC_RE.exec(minimum);
6289
+ if (!specMatch || !minimumMatch) return false;
6290
+ return compareMajorMinor(Number(specMatch[1]), Number(specMatch[2]), Number(minimumMatch[1]), Number(minimumMatch[2])) < 0;
6291
+ }
6292
+ function isDeclaredVersionSpecBelowMinimum(spec, minimum) {
6293
+ const normalized = spec.trim();
6294
+ if (PLAIN_VERSION_SPEC_RE.test(normalized)) return isConcreteVersionSpecBelowMinimum(normalized, minimum);
6295
+ const minimumMatch = VERSION_IN_SPEC_RE.exec(minimum);
6296
+ if (!minimumMatch) return false;
6297
+ const minimumMajor = Number(minimumMatch[1]);
6298
+ const minimumMinor = Number(minimumMatch[2]);
6299
+ for (const match of normalized.matchAll(UPPER_BOUND_RE)) if (compareMajorMinor(Number(match[1]), Number(match[2]), minimumMajor, minimumMinor) <= 0) return true;
6300
+ return false;
6301
+ }
6302
+ function resolveSupportedDependencyWarnings(cwd = process.cwd()) {
6303
+ const packageJsonPath = findNearestPackageJsonPath$2(cwd);
6304
+ if (!packageJsonPath) return [];
6305
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
6306
+ const installedConvexVersion = readInstalledDependencyVersion(packageJsonPath, "convex");
6307
+ if (installedConvexVersion && isConcreteVersionSpecBelowMinimum(installedConvexVersion, SUPPORTED_DEPENDENCY_VERSIONS.convex.minimum)) return [{
6308
+ packageName: "convex",
6309
+ current: installedConvexVersion,
6310
+ minimum: SUPPORTED_DEPENDENCY_VERSIONS.convex.minimum,
6311
+ installSpec: PINNED_CONVEX_INSTALL_SPEC
6312
+ }];
6313
+ const convexVersion = readDependencyVersion(packageJson, "convex");
6314
+ if (!convexVersion || !isDeclaredVersionSpecBelowMinimum(convexVersion, SUPPORTED_DEPENDENCY_VERSIONS.convex.minimum)) return [];
6315
+ return [{
6316
+ packageName: "convex",
6317
+ current: convexVersion,
6318
+ minimum: SUPPORTED_DEPENDENCY_VERSIONS.convex.minimum,
6319
+ installSpec: PINNED_CONVEX_INSTALL_SPEC
6320
+ }];
6321
+ }
6224
6322
 
6225
6323
  //#endregion
6226
6324
  //#region src/cli/registry/dependencies.ts
@@ -6257,7 +6355,7 @@ const resolvePackageJsonInstallTarget = () => {
6257
6355
  const resolveBunPeerWarningPreinstallSpecs = () => {
6258
6356
  const { packageJsonPath, packageJson } = resolvePackageJsonInstallTarget();
6259
6357
  if (!packageJsonPath || !packageJson) return [];
6260
- if (!(hasDependency(packageJson, "kitcn") || hasDependency(packageJson, "better-auth") || hasDependency(packageJson, "@convex-dev/better-auth"))) return [];
6358
+ if (!(hasDependency(packageJson, "kitcn") || hasDependency(packageJson, "better-auth"))) return [];
6261
6359
  if (hasDependency(packageJson, getPackageNameFromInstallSpec(OPENTELEMETRY_API_INSTALL_SPEC))) return [];
6262
6360
  const bunLockPath = join(dirname(packageJsonPath), BUN_LOCK_PATH);
6263
6361
  if (!fs.existsSync(bunLockPath)) return [];
@@ -6308,25 +6406,25 @@ const resolveMissingDependencyHints = (dependencyHints) => {
6308
6406
  };
6309
6407
  const applyDependencyHintsInstall = async (dependencyHints, execaFn) => {
6310
6408
  const preinstalledSpecs = await applyBunPeerWarningPreinstall(execaFn);
6311
- const missingDependencyHints = resolveMissingDependencyHints(dependencyHints).filter((dependencyHint) => !preinstalledSpecs.includes(dependencyHint));
6312
- if (missingDependencyHints.length === 0) return preinstalledSpecs;
6409
+ const installSpecs = resolveMissingDependencyHints(dependencyHints).filter((dependencyHint) => !preinstalledSpecs.includes(dependencyHint)).map((dependencyHint) => resolveSupportedDependencyInstallSpec(dependencyHint));
6410
+ if (installSpecs.length === 0) return preinstalledSpecs;
6313
6411
  const { packageJsonPath } = resolvePackageJsonInstallTarget();
6314
- await execaFn("bun", ["add", ...missingDependencyHints], {
6412
+ await execaFn("bun", ["add", ...installSpecs], {
6315
6413
  cwd: dirname(packageJsonPath),
6316
6414
  stdio: "inherit"
6317
6415
  });
6318
- return [...preinstalledSpecs, ...missingDependencyHints];
6416
+ return [...preinstalledSpecs, ...installSpecs];
6319
6417
  };
6320
6418
  const applyPlanningDependencyInstall = async (dependencySpecs, execaFn) => {
6321
6419
  const preinstalledSpecs = await applyBunPeerWarningPreinstall(execaFn);
6322
- const missingDependencySpecs = resolveMissingDependencyHints(dependencySpecs).filter((dependencySpec) => !preinstalledSpecs.includes(dependencySpec));
6323
- if (missingDependencySpecs.length === 0) return preinstalledSpecs;
6420
+ const installSpecs = resolveMissingDependencyHints(dependencySpecs).filter((dependencySpec) => !preinstalledSpecs.includes(dependencySpec)).map((dependencySpec) => resolveSupportedDependencyInstallSpec(dependencySpec));
6421
+ if (installSpecs.length === 0) return preinstalledSpecs;
6324
6422
  const { packageJsonPath } = resolvePackageJsonInstallTarget();
6325
- await execaFn("bun", ["add", ...missingDependencySpecs], {
6423
+ await execaFn("bun", ["add", ...installSpecs], {
6326
6424
  cwd: dirname(packageJsonPath),
6327
6425
  stdio: "inherit"
6328
6426
  });
6329
- return [...preinstalledSpecs, ...missingDependencySpecs];
6427
+ return [...preinstalledSpecs, ...installSpecs];
6330
6428
  };
6331
6429
  const applyPluginDependencyInstall = async (install, execaFn) => {
6332
6430
  if (install.skipped || !install.packageName || !install.packageJsonPath) return install;
@@ -8633,7 +8731,8 @@ import {
8633
8731
  useSignUpMutationOptions,
8634
8732
  } from '@/lib/convex/auth-client';
8635
8733
 
8636
- export const Route = createFileRoute('/auth' as never)({
8734
+ // @ts-ignore routeTree.gen.ts is refreshed by TanStack Router during dev/build.
8735
+ export const Route = createFileRoute('/auth')({
8637
8736
  component: AuthPage,
8638
8737
  });
8639
8738
 
@@ -8790,7 +8889,8 @@ const AUTH_START_ROUTE_TEMPLATE = `import { createFileRoute } from '@tanstack/re
8790
8889
 
8791
8890
  import { handler } from '@/lib/convex/auth-server';
8792
8891
 
8793
- export const Route = createFileRoute('/api/auth/$' as never)({
8892
+ // @ts-ignore routeTree.gen.ts is refreshed by TanStack Router during dev/build.
8893
+ export const Route = createFileRoute('/api/auth/$')({
8794
8894
  server: {
8795
8895
  handlers: {
8796
8896
  GET: ({ request }) => handler(request),
@@ -9297,7 +9397,7 @@ const DEFAULT_AUTH_SCHEMA_ENV = {
9297
9397
  SITE_URL: "http://localhost:3000"
9298
9398
  };
9299
9399
  const loadGetAuthTables = async () => (await import("better-auth/db")).getAuthTables;
9300
- const loadConvexAuthPlugin = async () => (await import("@convex-dev/better-auth/plugins")).convex;
9400
+ const loadConvexAuthPlugin = async () => (await import("./convex-plugin-tWTDqoKJ.mjs")).convex;
9301
9401
  const ts$1 = createTypeScriptProxy();
9302
9402
  const withAuthSchemaEnv = async (run) => {
9303
9403
  const globalScope = globalThis;
@@ -9537,8 +9637,8 @@ const AUTH_CONVEX_FILES = [
9537
9637
  target: "functions",
9538
9638
  content: AUTH_CONVEX_TEMPLATE,
9539
9639
  requires: ["auth-config-convex"],
9540
- dependencyHintMessage: "Auth runtime depends on OpenTelemetry API.",
9541
- dependencyHints: [OPENTELEMETRY_API_INSTALL_SPEC]
9640
+ dependencyHintMessage: "Auth runtime depends on OpenTelemetry API and kitcn runtime helpers.",
9641
+ dependencyHints: [OPENTELEMETRY_API_INSTALL_SPEC, "kitcn"]
9542
9642
  }),
9543
9643
  createRegistryFile({
9544
9644
  id: "auth-client-convex",
@@ -12453,7 +12553,6 @@ const createSpinner = (text, options = {}) => {
12453
12553
  //#region src/cli/backend-core.ts
12454
12554
  const __filename = fileURLToPath(import.meta.url);
12455
12555
  const __dirname = dirname(__filename);
12456
- let ownVersion;
12457
12556
  const ts = createTypeScriptProxy();
12458
12557
  const require = createRequire(import.meta.url);
12459
12558
  const realConvex = join(dirname(require.resolve("convex/package.json")), "bin/main.js");
@@ -12463,7 +12562,7 @@ const TS_EXTENSION_RE = /\.ts$/;
12463
12562
  const LEADING_SLASHES_RE = /^\/+/;
12464
12563
  const AGGREGATE_STATE_RELATIVE_PATH = join(".convex", "kitcn", "aggregate-backfill-state.json");
12465
12564
  const AGGREGATE_STATE_VERSION = 1;
12466
- const INIT_SHADCN_PACKAGE_SPEC = "shadcn@4.0.1";
12565
+ const INIT_SHADCN_PACKAGE_SPEC = "shadcn@4.3.0";
12467
12566
  const INIT_LOCAL_BOOTSTRAP_TIMEOUT_MS = 3e4;
12468
12567
  const LOCAL_BACKEND_NOT_RUNNING_RE = /Local backend isn't running/i;
12469
12568
  const INIT_GENERATED_SERVER_STUB_TEMPLATE = `// @ts-nocheck
@@ -12671,30 +12770,6 @@ function createCommandEnv(overrides) {
12671
12770
  ...overrides
12672
12771
  };
12673
12772
  }
12674
- function resolveOwnPackageJsonPath(filePath) {
12675
- let current = dirname(filePath);
12676
- while (true) {
12677
- const candidate = join(current, "package.json");
12678
- if (fs.existsSync(candidate)) {
12679
- if (JSON.parse(fs.readFileSync(candidate, "utf8")).name === "kitcn") return candidate;
12680
- }
12681
- const parent = dirname(current);
12682
- if (parent === current) throw new Error(`Could not find kitcn package.json from ${filePath}.`);
12683
- current = parent;
12684
- }
12685
- }
12686
- function readOwnVersion() {
12687
- if (ownVersion !== void 0) return ownVersion ?? void 0;
12688
- const packageJsonPath = resolveOwnPackageJsonPath(__filename);
12689
- ownVersion = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version ?? null;
12690
- return ownVersion ?? void 0;
12691
- }
12692
- function resolveScaffoldInstallSpec(env = process.env) {
12693
- const override = env[KITCN_INSTALL_SPEC_ENV]?.trim();
12694
- if (override) return override;
12695
- const version = readOwnVersion();
12696
- return version ? `kitcn@${version}` : "kitcn";
12697
- }
12698
12773
  const CONVEX_DEPLOYMENT_ENV_KEYS = [
12699
12774
  "CONVEX_DEPLOYMENT",
12700
12775
  "CONVEX_DEPLOY_KEY",
@@ -12715,6 +12790,9 @@ function createBackendCommandEnv(overrides) {
12715
12790
  ...overrides
12716
12791
  };
12717
12792
  }
12793
+ function getConvexDeploymentCommandEnv(env = process.env) {
12794
+ return Object.fromEntries(CONVEX_DEPLOYMENT_ENV_KEYS.map((key) => [key, env[key]]));
12795
+ }
12718
12796
  function hasRemoteConvexDeploymentEnv(env) {
12719
12797
  const deployment = env.CONVEX_DEPLOYMENT?.trim();
12720
12798
  if (deployment && !isLocalConvexDeploymentValue(deployment)) return true;
@@ -12914,8 +12992,15 @@ async function createProjectWithShadcn(params) {
12914
12992
  });
12915
12993
  }
12916
12994
  }
12995
+ function buildMissingShadcnScaffoldMessage(projectDir) {
12996
+ return [
12997
+ "Shadcn exited without creating a supported local scaffold.",
12998
+ "This usually means you chose the Custom preset.",
12999
+ `Run the generated shadcn command from ui.shadcn.com in ${normalizePath(relative(process.cwd(), projectDir) || ".")} then re-run \`kitcn init --yes\` to adopt it.`
13000
+ ].join(" ");
13001
+ }
12917
13002
  function moveStagedProjectIntoExistingDir(params) {
12918
- if (!fs.existsSync(params.stagedProjectDir)) throw new Error(`shadcn init did not create the staged project at ${params.stagedProjectDir}.`);
13003
+ if (!fs.existsSync(params.stagedProjectDir)) throw new Error(buildMissingShadcnScaffoldMessage(params.targetDir));
12919
13004
  if (!fs.existsSync(params.targetDir) || fs.readdirSync(params.targetDir).length > 0) throw new Error(`Cannot move staged project into non-empty target ${params.targetDir}.`);
12920
13005
  for (const entry of fs.readdirSync(params.stagedProjectDir)) fs.renameSync(join(params.stagedProjectDir, entry), join(params.targetDir, entry));
12921
13006
  }
@@ -13850,6 +13935,11 @@ async function runScaffoldCommandFlow(params) {
13850
13935
  execaFn: params.execaFn
13851
13936
  });
13852
13937
  const scaffoldProjectDir = resolveShadcnScaffoldProjectDir(params.projectDir, params.template);
13938
+ if (params.template && !resolveProjectScaffoldContext({
13939
+ cwd: scaffoldProjectDir,
13940
+ allowMissing: true,
13941
+ allowUnsupported: true
13942
+ })) throw new Error(buildMissingShadcnScaffoldMessage(scaffoldProjectDir));
13853
13943
  return withWorkingDirectory(scaffoldProjectDir, async () => {
13854
13944
  const config = params.loadCliConfigFn(params.configPath);
13855
13945
  const backend = resolveConfiguredBackend({
@@ -14395,13 +14485,9 @@ async function runConvexInitIfNeeded(params) {
14395
14485
  stderr: ""
14396
14486
  };
14397
14487
  const shouldUseLocalDevPreflight = getAggregateBackfillDeploymentKey(params.targetArgs ?? [], process.cwd(), params.env) === "local";
14398
- const agentModeOverride = params.yes && shouldUseLocalDevPreflight ? "anonymous" : params.env?.CONVEX_AGENT_MODE;
14399
14488
  const runCommand = async (commandArgs) => normalizeConvexCommandResult(await params.execaFn(params.backendAdapter.command, commandArgs, {
14400
14489
  cwd: process.cwd(),
14401
- env: createBackendCommandEnv({
14402
- ...params.env,
14403
- ...agentModeOverride ? { CONVEX_AGENT_MODE: agentModeOverride } : {}
14404
- }),
14490
+ env: createBackendCommandEnv(params.env),
14405
14491
  reject: false,
14406
14492
  stdio: "pipe"
14407
14493
  }));
@@ -14525,7 +14611,6 @@ async function runInitializationCodegen(params) {
14525
14611
  const initResult = await runConvexInitIfNeeded({
14526
14612
  execaFn: params.execaFn,
14527
14613
  backendAdapter: runtimeAdapter,
14528
- yes: params.yes,
14529
14614
  targetArgs: params.targetArgs
14530
14615
  });
14531
14616
  if (initResult.exitCode !== 0) throw new Error(`Failed to configure Convex project via \`convex init\`.\n${`${initResult.stdout}\n${initResult.stderr}`.trim()}`);
@@ -14671,6 +14756,7 @@ const VALID_BACKFILL_ENABLED = new Set([
14671
14756
  ]);
14672
14757
  const CONVEX_DEV_PRE_RUN_CONFLICT_FLAGS = [
14673
14758
  "--run",
14759
+ "--start",
14674
14760
  "--run-sh",
14675
14761
  "--run-component"
14676
14762
  ];
@@ -15337,4 +15423,4 @@ function isEntryPoint(entry, filename) {
15337
15423
  }
15338
15424
 
15339
15425
  //#endregion
15340
- export { resolveAddTemplateDefaults as $, resolveConfiguredBackend as A, runConvexInitIfNeeded as B, isInitialized as C, generateMeta as Ct, readPackageVersions as D, parseInitCommandArgs as E, highlighter as Et, runAfterScaffoldScript as F, trackProcess as G, runInitCommandFlow as H, runAggregateBackfillFlow as I, createSpinner as J, withLocalCodegenEnv as K, runAggregatePruneFlow as L, resolveInitProjectDir as M, resolveMigrationConfig as N, resolveBackfillConfig as O, resolveRunDeps as P, promptForScaffoldTemplateSelection as Q, runBackendFunction as R, isEntryPoint as S, stripConvexCommandNoise as St, parseBackendRunJson as T, logger as Tt, runMigrationCreate as U, runDevSchemaBackfillIfNeeded as V, runMigrationFlow as W, filterScaffoldTemplatePathMap as X, collectPluginScaffoldTemplates as Y, promptForPluginSelection as Z, formatInfoOutput as _, applyPluginDependencyInstall as _t, cleanup as a, getSupportedPluginKeys as at, hasRemoteConvexDeploymentEnv as b, resolveAuthEnvState as bt, createCommandEnv as c, resolvePluginScaffoldRoots as ct, extractBackfillCliOptions as d, getPluginLockfilePath as dt, resolvePluginPreset as et, extractConcaveRunTargetArgs as f, getSchemaFilePath as ft, formatDocsOutput as g, applyPlanningDependencyInstall as gt, extractResetCliOptions as h, applyDependencyHintsInstall as ht, buildInitializationPlan as i, getPluginCatalogEntry as it, resolveDocTopic as j, resolveCodegenTrimSegments as k, ensureConvexGitignoreEntry as l, assertSchemaFileExists as lt, extractMigrationDownOptions as m, resolveSchemaInstalledPlugins as mt, applyPluginInstallPlanFiles as n, resolveTemplateSelectionSource as nt, createBackendAdapter as o, isSupportedPluginKey as ot, extractMigrationCliOptions as p, readPluginLockfile as pt, withWorkingDirectory as q, assertNoRemovedDevPreRunFlag as r, resolveTemplatesByIdOrThrow as rt, createBackendCommandEnv as s, buildPluginInstallPlan as st, applyDependencyInstallPlan as t, resolvePresetScaffoldTemplates as tt, extractBackendRunTargetArgs as u, collectInstalledPluginKeys as ut, getAggregateBackfillDeploymentKey as v, inspectPluginDependencyInstall as vt, parseArgs as w, getConvexConfig as wt, isConvexDevPreRunConflictFlag as x, serializeEnvValue as xt, getDevAggregateBackfillStatePath as y, resolveProjectScaffoldContext as yt, runConfiguredCodegen as z };
15426
+ export { promptForScaffoldTemplateSelection as $, resolveCodegenTrimSegments as A, runConfiguredCodegen as B, isEntryPoint as C, serializeEnvValue as Ct, parseInitCommandArgs as D, logger as Dt, parseBackendRunJson as E, getConvexConfig as Et, resolveRunDeps as F, runMigrationFlow as G, runDevSchemaBackfillIfNeeded as H, runAfterScaffoldScript as I, withWorkingDirectory as J, trackProcess as K, runAggregateBackfillFlow as L, resolveDocTopic as M, resolveInitProjectDir as N, readPackageVersions as O, highlighter as Ot, resolveMigrationConfig as P, promptForPluginSelection as Q, runAggregatePruneFlow as R, isConvexDevPreRunConflictFlag as S, resolveAuthEnvState as St, parseArgs as T, generateMeta as Tt, runInitCommandFlow as U, runConvexInitIfNeeded as V, runMigrationCreate as W, collectPluginScaffoldTemplates as X, createSpinner as Y, filterScaffoldTemplatePathMap as Z, formatInfoOutput as _, applyPlanningDependencyInstall as _t, cleanup as a, getPluginCatalogEntry as at, getDevAggregateBackfillStatePath as b, resolveSupportedDependencyWarnings as bt, createCommandEnv as c, buildPluginInstallPlan as ct, extractBackfillCliOptions as d, collectInstalledPluginKeys as dt, resolveAddTemplateDefaults as et, extractConcaveRunTargetArgs as f, getPluginLockfilePath as ft, formatDocsOutput as g, applyDependencyHintsInstall as gt, extractResetCliOptions as h, resolveSchemaInstalledPlugins as ht, buildInitializationPlan as i, resolveTemplatesByIdOrThrow as it, resolveConfiguredBackend as j, resolveBackfillConfig as k, ensureConvexGitignoreEntry as l, resolvePluginScaffoldRoots as lt, extractMigrationDownOptions as m, readPluginLockfile as mt, applyPluginInstallPlanFiles as n, resolvePresetScaffoldTemplates as nt, createBackendAdapter as o, getSupportedPluginKeys as ot, extractMigrationCliOptions as p, getSchemaFilePath as pt, withLocalCodegenEnv as q, assertNoRemovedDevPreRunFlag as r, resolveTemplateSelectionSource as rt, createBackendCommandEnv as s, isSupportedPluginKey as st, applyDependencyInstallPlan as t, resolvePluginPreset as tt, extractBackendRunTargetArgs as u, assertSchemaFileExists as ut, getAggregateBackfillDeploymentKey as v, applyPluginDependencyInstall as vt, isInitialized as w, stripConvexCommandNoise as wt, hasRemoteConvexDeploymentEnv as x, resolveProjectScaffoldContext as xt, getConvexDeploymentCommandEnv as y, inspectPluginDependencyInstall as yt, runBackendFunction as z };
@@ -1,6 +1,7 @@
1
- import { l as pick, o as vRequired, t as addFieldsToValidator } from "./validators-B7oIJCAp.js";
2
- import { n as customCtx, t as NoOp } from "./customFunctions-C0voKmtx.js";
3
- import { s as getTransformer } from "./transformer-DtDhR3Lc.js";
1
+ import { i as pick } from "./upstream-BR6sBLg3.js";
2
+ import { o as vRequired, t as addFieldsToValidator } from "./validators-C7LelqTN.js";
3
+ import { n as customCtx, t as NoOp } from "./customFunctions-DxEEO4Dq.js";
4
+ import { s as getTransformer } from "./transformer-C6pGVHqx.js";
4
5
  import { ConvexError, v } from "convex/values";
5
6
  import { HttpRouter, actionGeneric, httpActionGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, mutationGeneric, queryGeneric } from "convex/server";
6
7
  import { z } from "zod";
@@ -1,5 +1,5 @@
1
- import { i as getFunctionType, n as getFuncRef, t as buildMetaIndex } from "./meta-utils-0Pu0Nrap.js";
2
- import { s as getTransformer } from "./transformer-DtDhR3Lc.js";
1
+ import { i as getFunctionType, n as getFuncRef, t as buildMetaIndex } from "./meta-utils-D9K4fICl.js";
2
+ import { s as getTransformer } from "./transformer-C6pGVHqx.js";
3
3
  import { fetchAction, fetchMutation, fetchQuery } from "convex/nextjs";
4
4
 
5
5
  //#region src/server/caller.ts
@@ -114,7 +114,7 @@ function createLazyCaller(api, createContext) {
114
114
  /** biome-ignore-all lint/suspicious/noExplicitAny: lib */
115
115
  /**
116
116
  * Framework-agnostic caller factory.
117
- * getToken is passed as a parameter - decoupled from @convex-dev/better-auth.
117
+ * getToken is passed as a parameter so framework auth helpers stay decoupled.
118
118
  */
119
119
  const CONVEX_SITE_URL_RE = /\.convex\.site(?=\/|$)/;
120
120
  const getArgsAndOptions = (args, token, url) => [args[0], {