kitcn 0.12.26 → 0.13.0
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/aggregate/index.d.ts +1 -1
- package/dist/aggregate/index.js +1 -1
- package/dist/auth/client/index.d.ts +312 -4
- package/dist/auth/client/index.js +17 -5
- package/dist/auth/config/index.d.ts +1 -1
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/generated/index.js +1 -1
- package/dist/auth/http/index.d.ts +12 -9
- package/dist/auth/http/index.js +35 -6
- package/dist/auth/index.d.ts +292 -8
- package/dist/auth/index.js +29 -23
- package/dist/auth/nextjs/index.d.ts +4 -3
- package/dist/auth/nextjs/index.js +9 -4
- package/dist/auth/start/index.d.ts +13 -3
- package/dist/auth/start/index.js +97 -8
- package/dist/{backend-core-DtIbLptD.mjs → backend-core-CXmrWqdi.mjs} +126 -50
- package/dist/{builder-Cb6gloDB.js → builder-DBgto1yn.js} +4 -3
- package/dist/{caller-factory-cTXNvYdz.js → caller-factory-NEfgD5E0.js} +3 -3
- package/dist/cli.mjs +26 -26
- package/dist/convex-plugin-C3N9BB-J.js +275 -0
- package/dist/convex-plugin-tWTDqoKJ.mjs +276 -0
- package/dist/{create-schema-orm-DOyiNDCx.js → create-schema-orm-B3f2Kc8O.js} +1 -1
- package/dist/crpc/index.d.ts +2 -2
- package/dist/crpc/index.js +3 -3
- package/dist/{customFunctions-C0voKmtx.js → customFunctions-DxEEO4Dq.js} +2 -1
- package/dist/{generated-contract-disabled-21YxPk5W.d.ts → generated-contract-disabled-C_-KWRfT.d.ts} +4 -2
- package/dist/{http-types-BLFA9zS7.d.ts → http-types-zsMHb_QN.d.ts} +2 -2
- package/dist/{middleware-DkIhQXwg.js → middleware-Bg-PdtrI.js} +1 -1
- package/dist/{middleware-nS_qXecO.d.ts → middleware-DrtexzF3.d.ts} +1 -1
- package/dist/orm/index.d.ts +3 -3
- package/dist/orm/index.js +3 -3
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-AjLfkHyF.js → procedure-caller-DplSC7Us.js} +2 -2
- package/dist/{procedure-name-D-fDCBlo.d.ts → procedure-name-BCRBr6Po.d.ts} +3 -3
- package/dist/ratelimit/index.d.ts +2 -2
- package/dist/ratelimit/index.js +3 -3
- package/dist/react/index.d.ts +18 -14
- package/dist/react/index.js +14 -27
- package/dist/rsc/index.d.ts +4 -4
- package/dist/rsc/index.js +4 -4
- package/dist/{runtime-CtvJPkur.js → runtime-i6t-HoZn.js} +1 -1
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +4 -4
- package/dist/solid/index.d.ts +300 -4
- package/dist/token-B9Bjcqug.d.ts +13 -0
- package/dist/token-tpipF-7y.js +47 -0
- package/dist/{types-C6pQrnzD.d.ts → types-YHpe0rsb.d.ts} +1 -1
- package/dist/upstream-BR6sBLg3.js +84 -0
- package/dist/upstream-BUCdbLok.mjs +26 -0
- package/dist/{validators-B7oIJCAp.js → validators-C7LelqTN.js} +2 -84
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-DdjN63Io.d.ts → where-clause-compiler-TMppDl9g.d.ts} +51 -51
- package/package.json +5 -4
- package/skills/convex/references/features/auth.md +20 -0
- package/skills/convex/references/setup/auth.md +2 -0
- package/skills/convex/references/setup/index.md +5 -5
- package/skills/convex/references/setup/server.md +1 -1
- /package/dist/{api-entry-BUAh_K4k.js → api-entry-N3nBOlI2.js} +0 -0
- /package/dist/{context-utils-BvWW0Ilq.d.ts → context-utils-OMkMGhBk.d.ts} +0 -0
- /package/dist/{create-schema-odyF4kCy.js → create-schema-BXrKE2YY.js} +0 -0
- /package/dist/{error-BZEnI7Sq.js → error-Bvo7YEhk.js} +0 -0
- /package/dist/{generated-contract-disabled-Cih4eITO.js → generated-contract-disabled-BXaz7JCE.js} +0 -0
- /package/dist/{meta-utils-0Pu0Nrap.js → meta-utils-D9K4fICl.js} +0 -0
- /package/dist/{query-context-CFZqIvD7.d.ts → query-context-CNo9ffvI.d.ts} +0 -0
- /package/dist/{query-context-B8o6-8kC.js → query-context-ydn9kb6P.js} +0 -0
- /package/dist/{query-options-Dw7cOyXl.js → query-options-C96zLANM.js} +0 -0
- /package/dist/{transformer-DtDhR3Lc.js → transformer-C6pGVHqx.js} +0 -0
- /package/dist/{types-BiJE7qxR.d.ts → types-BCl8gfGy.d.ts} +0 -0
- /package/dist/{types-a-RHmrDZ.d.ts → types-CnTpHR1F.d.ts} +0 -0
- /package/dist/{types-BTb_4BaU.d.ts → types-DF2cg_w0.d.ts} +0 -0
- /package/dist/{validators-vzRKjBJC.d.ts → validators-BhsByJeg.d.ts} +0 -0
package/dist/auth/start/index.js
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
30
|
-
const
|
|
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
|
-
|
|
33
|
-
|
|
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 };
|
|
@@ -2446,6 +2446,7 @@ const createProjectJiti = (cwd = process.cwd()) => createJiti(cwd, {
|
|
|
2446
2446
|
interopDefault: true,
|
|
2447
2447
|
jsx: { runtime: "automatic" },
|
|
2448
2448
|
moduleCache: false,
|
|
2449
|
+
tryNative: false,
|
|
2449
2450
|
alias: {
|
|
2450
2451
|
...buildTsconfigPathAliases(cwd),
|
|
2451
2452
|
...buildLocalPackageExportAliases(cwd, "kitcn"),
|
|
@@ -6158,14 +6159,18 @@ function resolveProjectScaffoldContext(params = {}) {
|
|
|
6158
6159
|
//#endregion
|
|
6159
6160
|
//#region src/cli/supported-dependencies.ts
|
|
6160
6161
|
const EXACT_VERSION_RE = /^(\d+)\.(\d+)\.\d+$/;
|
|
6161
|
-
const
|
|
6162
|
-
const
|
|
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";
|
|
6163
6167
|
const SUPPORTED_HONO_VERSION = "4.12.9";
|
|
6164
6168
|
const SUPPORTED_OPENTELEMETRY_API_VERSION = "1.9.0";
|
|
6165
6169
|
const SUPPORTED_TANSTACK_REACT_QUERY_VERSION = "5.95.2";
|
|
6166
6170
|
const SUPPORTED_ZOD_VERSION = "4.3.6";
|
|
6167
6171
|
const KITCN_INSTALL_SPEC_ENV = "KITCN_INSTALL_SPEC";
|
|
6168
6172
|
const KITCN_RESEND_INSTALL_SPEC_ENV = "KITCN_RESEND_INSTALL_SPEC";
|
|
6173
|
+
let ownVersion;
|
|
6169
6174
|
function getMinimumVersionRange(version) {
|
|
6170
6175
|
const match = EXACT_VERSION_RE.exec(version);
|
|
6171
6176
|
if (!match) throw new Error(`Unsupported exact version "${version}". Expected x.y.z format.`);
|
|
@@ -6188,10 +6193,37 @@ const LOCAL_INSTALL_SPEC_ENV_BY_PACKAGE_NAME = {
|
|
|
6188
6193
|
"@kitcn/resend": KITCN_RESEND_INSTALL_SPEC_ENV
|
|
6189
6194
|
};
|
|
6190
6195
|
function resolveSupportedDependencyInstallSpec(spec, env = process.env) {
|
|
6196
|
+
if (getPackageNameFromInstallSpec(spec) === "kitcn") return resolveScaffoldInstallSpec(env);
|
|
6191
6197
|
const envKey = LOCAL_INSTALL_SPEC_ENV_BY_PACKAGE_NAME[getPackageNameFromInstallSpec(spec)];
|
|
6192
6198
|
const override = envKey ? env[envKey]?.trim() : void 0;
|
|
6193
6199
|
return override && override.length > 0 ? override : spec;
|
|
6194
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
|
+
}
|
|
6195
6227
|
const SUPPORTED_DEPENDENCY_VERSIONS = {
|
|
6196
6228
|
convex: {
|
|
6197
6229
|
exact: SUPPORTED_CONVEX_VERSION,
|
|
@@ -6220,6 +6252,73 @@ const BASELINE_DEPENDENCY_INSTALL_SPECS = [
|
|
|
6220
6252
|
PINNED_HONO_INSTALL_SPEC
|
|
6221
6253
|
];
|
|
6222
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
|
+
}
|
|
6223
6322
|
|
|
6224
6323
|
//#endregion
|
|
6225
6324
|
//#region src/cli/registry/dependencies.ts
|
|
@@ -6256,7 +6355,7 @@ const resolvePackageJsonInstallTarget = () => {
|
|
|
6256
6355
|
const resolveBunPeerWarningPreinstallSpecs = () => {
|
|
6257
6356
|
const { packageJsonPath, packageJson } = resolvePackageJsonInstallTarget();
|
|
6258
6357
|
if (!packageJsonPath || !packageJson) return [];
|
|
6259
|
-
if (!(hasDependency(packageJson, "kitcn") || hasDependency(packageJson, "better-auth")
|
|
6358
|
+
if (!(hasDependency(packageJson, "kitcn") || hasDependency(packageJson, "better-auth"))) return [];
|
|
6260
6359
|
if (hasDependency(packageJson, getPackageNameFromInstallSpec(OPENTELEMETRY_API_INSTALL_SPEC))) return [];
|
|
6261
6360
|
const bunLockPath = join(dirname(packageJsonPath), BUN_LOCK_PATH);
|
|
6262
6361
|
if (!fs.existsSync(bunLockPath)) return [];
|
|
@@ -6307,25 +6406,25 @@ const resolveMissingDependencyHints = (dependencyHints) => {
|
|
|
6307
6406
|
};
|
|
6308
6407
|
const applyDependencyHintsInstall = async (dependencyHints, execaFn) => {
|
|
6309
6408
|
const preinstalledSpecs = await applyBunPeerWarningPreinstall(execaFn);
|
|
6310
|
-
const
|
|
6311
|
-
if (
|
|
6409
|
+
const installSpecs = resolveMissingDependencyHints(dependencyHints).filter((dependencyHint) => !preinstalledSpecs.includes(dependencyHint)).map((dependencyHint) => resolveSupportedDependencyInstallSpec(dependencyHint));
|
|
6410
|
+
if (installSpecs.length === 0) return preinstalledSpecs;
|
|
6312
6411
|
const { packageJsonPath } = resolvePackageJsonInstallTarget();
|
|
6313
|
-
await execaFn("bun", ["add", ...
|
|
6412
|
+
await execaFn("bun", ["add", ...installSpecs], {
|
|
6314
6413
|
cwd: dirname(packageJsonPath),
|
|
6315
6414
|
stdio: "inherit"
|
|
6316
6415
|
});
|
|
6317
|
-
return [...preinstalledSpecs, ...
|
|
6416
|
+
return [...preinstalledSpecs, ...installSpecs];
|
|
6318
6417
|
};
|
|
6319
6418
|
const applyPlanningDependencyInstall = async (dependencySpecs, execaFn) => {
|
|
6320
6419
|
const preinstalledSpecs = await applyBunPeerWarningPreinstall(execaFn);
|
|
6321
|
-
const
|
|
6322
|
-
if (
|
|
6420
|
+
const installSpecs = resolveMissingDependencyHints(dependencySpecs).filter((dependencySpec) => !preinstalledSpecs.includes(dependencySpec)).map((dependencySpec) => resolveSupportedDependencyInstallSpec(dependencySpec));
|
|
6421
|
+
if (installSpecs.length === 0) return preinstalledSpecs;
|
|
6323
6422
|
const { packageJsonPath } = resolvePackageJsonInstallTarget();
|
|
6324
|
-
await execaFn("bun", ["add", ...
|
|
6423
|
+
await execaFn("bun", ["add", ...installSpecs], {
|
|
6325
6424
|
cwd: dirname(packageJsonPath),
|
|
6326
6425
|
stdio: "inherit"
|
|
6327
6426
|
});
|
|
6328
|
-
return [...preinstalledSpecs, ...
|
|
6427
|
+
return [...preinstalledSpecs, ...installSpecs];
|
|
6329
6428
|
};
|
|
6330
6429
|
const applyPluginDependencyInstall = async (install, execaFn) => {
|
|
6331
6430
|
if (install.skipped || !install.packageName || !install.packageJsonPath) return install;
|
|
@@ -8028,7 +8127,7 @@ const AUTH_CONVEX_CLIENT_TEMPLATE = `import { createAuthClient } from 'better-au
|
|
|
8028
8127
|
import { convexClient } from 'kitcn/auth/client';
|
|
8029
8128
|
|
|
8030
8129
|
export const authClient = createAuthClient({
|
|
8031
|
-
baseURL: process.env.
|
|
8130
|
+
baseURL: process.env.NEXT_PUBLIC_SITE_URL!,
|
|
8032
8131
|
plugins: [convexClient()],
|
|
8033
8132
|
});
|
|
8034
8133
|
`;
|
|
@@ -8036,7 +8135,7 @@ const AUTH_CONVEX_REACT_CLIENT_TEMPLATE = `import { createAuthClient } from 'bet
|
|
|
8036
8135
|
import { convexClient } from 'kitcn/auth/client';
|
|
8037
8136
|
|
|
8038
8137
|
export const authClient = createAuthClient({
|
|
8039
|
-
baseURL: import.meta.env.
|
|
8138
|
+
baseURL: import.meta.env.VITE_SITE_URL!,
|
|
8040
8139
|
plugins: [convexClient()],
|
|
8041
8140
|
});
|
|
8042
8141
|
`;
|
|
@@ -8632,7 +8731,8 @@ import {
|
|
|
8632
8731
|
useSignUpMutationOptions,
|
|
8633
8732
|
} from '@/lib/convex/auth-client';
|
|
8634
8733
|
|
|
8635
|
-
|
|
8734
|
+
// @ts-ignore routeTree.gen.ts is refreshed by TanStack Router during dev/build.
|
|
8735
|
+
export const Route = createFileRoute('/auth')({
|
|
8636
8736
|
component: AuthPage,
|
|
8637
8737
|
});
|
|
8638
8738
|
|
|
@@ -8789,7 +8889,8 @@ const AUTH_START_ROUTE_TEMPLATE = `import { createFileRoute } from '@tanstack/re
|
|
|
8789
8889
|
|
|
8790
8890
|
import { handler } from '@/lib/convex/auth-server';
|
|
8791
8891
|
|
|
8792
|
-
|
|
8892
|
+
// @ts-ignore routeTree.gen.ts is refreshed by TanStack Router during dev/build.
|
|
8893
|
+
export const Route = createFileRoute('/api/auth/$')({
|
|
8793
8894
|
server: {
|
|
8794
8895
|
handlers: {
|
|
8795
8896
|
GET: ({ request }) => handler(request),
|
|
@@ -9283,6 +9384,7 @@ const AUTH_SCHEMA_TEMPLATE_IDS = new Set(["auth-schema", "auth-schema-convex"]);
|
|
|
9283
9384
|
const USER_OWNED_AUTH_TEMPLATE_IDS = new Set([
|
|
9284
9385
|
"auth-config",
|
|
9285
9386
|
"auth-config-convex",
|
|
9387
|
+
"auth-client-convex",
|
|
9286
9388
|
"auth-runtime",
|
|
9287
9389
|
"auth-runtime-convex"
|
|
9288
9390
|
]);
|
|
@@ -9295,7 +9397,7 @@ const DEFAULT_AUTH_SCHEMA_ENV = {
|
|
|
9295
9397
|
SITE_URL: "http://localhost:3000"
|
|
9296
9398
|
};
|
|
9297
9399
|
const loadGetAuthTables = async () => (await import("better-auth/db")).getAuthTables;
|
|
9298
|
-
const loadConvexAuthPlugin = async () => (await import("
|
|
9400
|
+
const loadConvexAuthPlugin = async () => (await import("./convex-plugin-tWTDqoKJ.mjs")).convex;
|
|
9299
9401
|
const ts$1 = createTypeScriptProxy();
|
|
9300
9402
|
const withAuthSchemaEnv = async (run) => {
|
|
9301
9403
|
const globalScope = globalThis;
|
|
@@ -9535,8 +9637,8 @@ const AUTH_CONVEX_FILES = [
|
|
|
9535
9637
|
target: "functions",
|
|
9536
9638
|
content: AUTH_CONVEX_TEMPLATE,
|
|
9537
9639
|
requires: ["auth-config-convex"],
|
|
9538
|
-
dependencyHintMessage: "Auth runtime depends on OpenTelemetry API.",
|
|
9539
|
-
dependencyHints: [OPENTELEMETRY_API_INSTALL_SPEC]
|
|
9640
|
+
dependencyHintMessage: "Auth runtime depends on OpenTelemetry API and kitcn runtime helpers.",
|
|
9641
|
+
dependencyHints: [OPENTELEMETRY_API_INSTALL_SPEC, "kitcn"]
|
|
9540
9642
|
}),
|
|
9541
9643
|
createRegistryFile({
|
|
9542
9644
|
id: "auth-client-convex",
|
|
@@ -12451,7 +12553,6 @@ const createSpinner = (text, options = {}) => {
|
|
|
12451
12553
|
//#region src/cli/backend-core.ts
|
|
12452
12554
|
const __filename = fileURLToPath(import.meta.url);
|
|
12453
12555
|
const __dirname = dirname(__filename);
|
|
12454
|
-
let ownVersion;
|
|
12455
12556
|
const ts = createTypeScriptProxy();
|
|
12456
12557
|
const require = createRequire(import.meta.url);
|
|
12457
12558
|
const realConvex = join(dirname(require.resolve("convex/package.json")), "bin/main.js");
|
|
@@ -12669,30 +12770,6 @@ function createCommandEnv(overrides) {
|
|
|
12669
12770
|
...overrides
|
|
12670
12771
|
};
|
|
12671
12772
|
}
|
|
12672
|
-
function resolveOwnPackageJsonPath(filePath) {
|
|
12673
|
-
let current = dirname(filePath);
|
|
12674
|
-
while (true) {
|
|
12675
|
-
const candidate = join(current, "package.json");
|
|
12676
|
-
if (fs.existsSync(candidate)) {
|
|
12677
|
-
if (JSON.parse(fs.readFileSync(candidate, "utf8")).name === "kitcn") return candidate;
|
|
12678
|
-
}
|
|
12679
|
-
const parent = dirname(current);
|
|
12680
|
-
if (parent === current) throw new Error(`Could not find kitcn package.json from ${filePath}.`);
|
|
12681
|
-
current = parent;
|
|
12682
|
-
}
|
|
12683
|
-
}
|
|
12684
|
-
function readOwnVersion() {
|
|
12685
|
-
if (ownVersion !== void 0) return ownVersion ?? void 0;
|
|
12686
|
-
const packageJsonPath = resolveOwnPackageJsonPath(__filename);
|
|
12687
|
-
ownVersion = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version ?? null;
|
|
12688
|
-
return ownVersion ?? void 0;
|
|
12689
|
-
}
|
|
12690
|
-
function resolveScaffoldInstallSpec(env = process.env) {
|
|
12691
|
-
const override = env[KITCN_INSTALL_SPEC_ENV]?.trim();
|
|
12692
|
-
if (override) return override;
|
|
12693
|
-
const version = readOwnVersion();
|
|
12694
|
-
return version ? `kitcn@${version}` : "kitcn";
|
|
12695
|
-
}
|
|
12696
12773
|
const CONVEX_DEPLOYMENT_ENV_KEYS = [
|
|
12697
12774
|
"CONVEX_DEPLOYMENT",
|
|
12698
12775
|
"CONVEX_DEPLOY_KEY",
|
|
@@ -12713,6 +12790,9 @@ function createBackendCommandEnv(overrides) {
|
|
|
12713
12790
|
...overrides
|
|
12714
12791
|
};
|
|
12715
12792
|
}
|
|
12793
|
+
function getConvexDeploymentCommandEnv(env = process.env) {
|
|
12794
|
+
return Object.fromEntries(CONVEX_DEPLOYMENT_ENV_KEYS.map((key) => [key, env[key]]));
|
|
12795
|
+
}
|
|
12716
12796
|
function hasRemoteConvexDeploymentEnv(env) {
|
|
12717
12797
|
const deployment = env.CONVEX_DEPLOYMENT?.trim();
|
|
12718
12798
|
if (deployment && !isLocalConvexDeploymentValue(deployment)) return true;
|
|
@@ -14393,13 +14473,9 @@ async function runConvexInitIfNeeded(params) {
|
|
|
14393
14473
|
stderr: ""
|
|
14394
14474
|
};
|
|
14395
14475
|
const shouldUseLocalDevPreflight = getAggregateBackfillDeploymentKey(params.targetArgs ?? [], process.cwd(), params.env) === "local";
|
|
14396
|
-
const agentModeOverride = params.yes && shouldUseLocalDevPreflight ? "anonymous" : params.env?.CONVEX_AGENT_MODE;
|
|
14397
14476
|
const runCommand = async (commandArgs) => normalizeConvexCommandResult(await params.execaFn(params.backendAdapter.command, commandArgs, {
|
|
14398
14477
|
cwd: process.cwd(),
|
|
14399
|
-
env: createBackendCommandEnv(
|
|
14400
|
-
...params.env,
|
|
14401
|
-
...agentModeOverride ? { CONVEX_AGENT_MODE: agentModeOverride } : {}
|
|
14402
|
-
}),
|
|
14478
|
+
env: createBackendCommandEnv(params.env),
|
|
14403
14479
|
reject: false,
|
|
14404
14480
|
stdio: "pipe"
|
|
14405
14481
|
}));
|
|
@@ -14523,7 +14599,6 @@ async function runInitializationCodegen(params) {
|
|
|
14523
14599
|
const initResult = await runConvexInitIfNeeded({
|
|
14524
14600
|
execaFn: params.execaFn,
|
|
14525
14601
|
backendAdapter: runtimeAdapter,
|
|
14526
|
-
yes: params.yes,
|
|
14527
14602
|
targetArgs: params.targetArgs
|
|
14528
14603
|
});
|
|
14529
14604
|
if (initResult.exitCode !== 0) throw new Error(`Failed to configure Convex project via \`convex init\`.\n${`${initResult.stdout}\n${initResult.stderr}`.trim()}`);
|
|
@@ -14669,6 +14744,7 @@ const VALID_BACKFILL_ENABLED = new Set([
|
|
|
14669
14744
|
]);
|
|
14670
14745
|
const CONVEX_DEV_PRE_RUN_CONFLICT_FLAGS = [
|
|
14671
14746
|
"--run",
|
|
14747
|
+
"--start",
|
|
14672
14748
|
"--run-sh",
|
|
14673
14749
|
"--run-component"
|
|
14674
14750
|
];
|
|
@@ -15335,4 +15411,4 @@ function isEntryPoint(entry, filename) {
|
|
|
15335
15411
|
}
|
|
15336
15412
|
|
|
15337
15413
|
//#endregion
|
|
15338
|
-
export {
|
|
15414
|
+
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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-
|
|
2
|
-
import { s as getTransformer } from "./transformer-
|
|
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
|
|
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], {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as promptForScaffoldTemplateSelection, A as resolveCodegenTrimSegments, B as runConfiguredCodegen, C as isEntryPoint, Ct as serializeEnvValue, D as parseInitCommandArgs, Dt as logger, E as parseBackendRunJson, F as resolveRunDeps, G as runMigrationFlow, H as runDevSchemaBackfillIfNeeded, I as runAfterScaffoldScript, J as withWorkingDirectory, K as trackProcess, L as runAggregateBackfillFlow, M as resolveDocTopic, N as resolveInitProjectDir, O as readPackageVersions, Ot as highlighter, P as resolveMigrationConfig, Q as promptForPluginSelection, R as runAggregatePruneFlow, S as isConvexDevPreRunConflictFlag, St as resolveAuthEnvState, T as parseArgs, U as runInitCommandFlow, V as runConvexInitIfNeeded, W as runMigrationCreate, X as collectPluginScaffoldTemplates, Y as createSpinner, Z as filterScaffoldTemplatePathMap, _ as formatInfoOutput, _t as applyPlanningDependencyInstall, a as cleanup, at as getPluginCatalogEntry, b as getDevAggregateBackfillStatePath, bt as resolveSupportedDependencyWarnings, c as createCommandEnv, ct as buildPluginInstallPlan, d as extractBackfillCliOptions, dt as collectInstalledPluginKeys, et as resolveAddTemplateDefaults, f as extractConcaveRunTargetArgs, ft as getPluginLockfilePath, g as formatDocsOutput, gt as applyDependencyHintsInstall, h as extractResetCliOptions, ht as resolveSchemaInstalledPlugins, i as buildInitializationPlan, it as resolveTemplatesByIdOrThrow, j as resolveConfiguredBackend, k as resolveBackfillConfig, l as ensureConvexGitignoreEntry, lt as resolvePluginScaffoldRoots, m as extractMigrationDownOptions, mt as readPluginLockfile, n as applyPluginInstallPlanFiles, nt as resolvePresetScaffoldTemplates, o as createBackendAdapter, ot as getSupportedPluginKeys, p as extractMigrationCliOptions, pt as getSchemaFilePath, q as withLocalCodegenEnv, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplateSelectionSource, s as createBackendCommandEnv, st as isSupportedPluginKey, t as applyDependencyInstallPlan, tt as resolvePluginPreset, u as extractBackendRunTargetArgs, ut as assertSchemaFileExists, v as getAggregateBackfillDeploymentKey, vt as applyPluginDependencyInstall, w as isInitialized, wt as stripConvexCommandNoise, x as hasRemoteConvexDeploymentEnv, xt as resolveProjectScaffoldContext, y as getConvexDeploymentCommandEnv, yt as inspectPluginDependencyInstall, z as runBackendFunction } from "./backend-core-CXmrWqdi.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";
|
|
@@ -381,7 +381,7 @@ function filterDevStartupLine(rawLine) {
|
|
|
381
381
|
const line = stripConvexCommandNoise(rawLine).trim();
|
|
382
382
|
if (!line) return { kind: "skip" };
|
|
383
383
|
if (DEV_SUPPRESSED_LINE_PATTERNS.some((pattern) => pattern.test(line))) return { kind: "skip" };
|
|
384
|
-
if (line.includes("Finished running function \"init\"") || line.includes("
|
|
384
|
+
if (line.includes("Finished running function \"init\"") || line.includes("Convex AI files are not installed.") || line.includes("Preparing Convex functions...") || line.includes("Bundling component schemas and implementations") || line.includes("Uploading functions to Convex")) return { kind: "skip" };
|
|
385
385
|
if (DEV_READY_LINE_RE.test(line)) return {
|
|
386
386
|
kind: "ready",
|
|
387
387
|
message: line.toLowerCase().includes("concave") ? "Concave ready" : "Convex ready"
|
|
@@ -652,12 +652,6 @@ function resolveImplicitConvexRemoteDeploymentEnv(cwd = process.cwd()) {
|
|
|
652
652
|
CONVEX_SELF_HOSTED_ADMIN_KEY: parsed.CONVEX_SELF_HOSTED_ADMIN_KEY
|
|
653
653
|
};
|
|
654
654
|
}
|
|
655
|
-
function resolveImplicitConvexAnonymousAgentMode(cwd = process.cwd()) {
|
|
656
|
-
const envLocalPath = join(cwd, ".env.local");
|
|
657
|
-
if (!fs.existsSync(envLocalPath)) return;
|
|
658
|
-
const deployment = parseEnv(fs.readFileSync(envLocalPath, "utf8")).CONVEX_DEPLOYMENT?.trim();
|
|
659
|
-
if (deployment === "anonymous-agent" || deployment?.startsWith("anonymous:")) return "anonymous";
|
|
660
|
-
}
|
|
661
655
|
function resolveConvexEnvFileCommandEnv(args, cwd = process.cwd()) {
|
|
662
656
|
let envFilePath = null;
|
|
663
657
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -880,12 +874,11 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
880
874
|
const explicitConvexTargetArgs = extractBackendRunTargetArgs("convex", convexDevArgs);
|
|
881
875
|
const explicitConvexCommandEnv = resolveConvexEnvFileCommandEnv(convexDevArgs);
|
|
882
876
|
const implicitConvexCommandEnv = backend === "convex" && explicitConvexTargetArgs.length === 0 && explicitConvexCommandEnv === null ? resolveImplicitConvexRemoteDeploymentEnv() : null;
|
|
883
|
-
const implicitConvexAgentMode = backend === "convex" && explicitConvexTargetArgs.length === 0 && !explicitConvexCommandEnv?.CONVEX_AGENT_MODE && !implicitConvexCommandEnv?.CONVEX_AGENT_MODE ? resolveImplicitConvexAnonymousAgentMode() : void 0;
|
|
884
877
|
const effectiveConvexCommandEnv = explicitConvexCommandEnv ?? implicitConvexCommandEnv;
|
|
885
878
|
const preRunFunction = config.dev.preRun;
|
|
886
879
|
if (bootstrap && backend !== "convex") throw new Error("`kitcn dev --bootstrap` is only supported for backend convex.");
|
|
887
880
|
if (preRunFunction && backend === "concave") throw new Error("`dev.preRun` is only supported for backend convex. Concave dev has no equivalent `--run` flow.");
|
|
888
|
-
if (preRunFunction && convexDevArgs.some((arg) => isConvexDevPreRunConflictFlag(arg))) throw new Error("`dev.preRun` cannot be combined with Convex dev run flags (`--run`, `--run-sh`, `--run-component`).");
|
|
881
|
+
if (preRunFunction && convexDevArgs.some((arg) => isConvexDevPreRunConflictFlag(arg))) throw new Error("`dev.preRun` cannot be combined with Convex dev run flags (`--run`, `--start`, `--run-sh`, `--run-component`).");
|
|
889
882
|
const backendAdapter = createBackendAdapter({
|
|
890
883
|
backend,
|
|
891
884
|
realConvexPath,
|
|
@@ -926,8 +919,7 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
926
919
|
echoOutput: false,
|
|
927
920
|
env: {
|
|
928
921
|
...localNodeEnvOverrides,
|
|
929
|
-
...effectiveConvexCommandEnv
|
|
930
|
-
...implicitConvexAgentMode ? { CONVEX_AGENT_MODE: implicitConvexAgentMode } : {}
|
|
922
|
+
...effectiveConvexCommandEnv
|
|
931
923
|
},
|
|
932
924
|
targetArgs
|
|
933
925
|
});
|
|
@@ -980,7 +972,6 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
980
972
|
env: createBackendCommandEnv({
|
|
981
973
|
...localNodeEnvOverrides,
|
|
982
974
|
...effectiveConvexCommandEnv,
|
|
983
|
-
...implicitConvexAgentMode ? { CONVEX_AGENT_MODE: implicitConvexAgentMode } : {},
|
|
984
975
|
...concaveLocalDevContract?.backendEnv
|
|
985
976
|
}),
|
|
986
977
|
reject: false
|
|
@@ -1781,6 +1772,7 @@ const handleDeployCommand = async (argv, deps = {}) => {
|
|
|
1781
1772
|
const { remainingArgs: deployArgsWithoutMigrationFlags, overrides: deployMigrationOverrides } = extractMigrationCliOptions(parsed.convexArgs);
|
|
1782
1773
|
const { remainingArgs: deployCommandArgs, overrides: deployBackfillOverrides } = extractBackfillCliOptions(deployArgsWithoutMigrationFlags);
|
|
1783
1774
|
const deployArgs = [...config.deploy.args, ...deployCommandArgs];
|
|
1775
|
+
const deployCommandEnv = backend === "convex" ? getConvexDeploymentCommandEnv() : void 0;
|
|
1784
1776
|
const deployResult = await execaFn(backendAdapter.command, [
|
|
1785
1777
|
...backendAdapter.argsPrefix,
|
|
1786
1778
|
"deploy",
|
|
@@ -1788,7 +1780,7 @@ const handleDeployCommand = async (argv, deps = {}) => {
|
|
|
1788
1780
|
], {
|
|
1789
1781
|
stdio: "inherit",
|
|
1790
1782
|
cwd: process.cwd(),
|
|
1791
|
-
env: createBackendCommandEnv(),
|
|
1783
|
+
env: createBackendCommandEnv(deployCommandEnv),
|
|
1792
1784
|
reject: false
|
|
1793
1785
|
});
|
|
1794
1786
|
if ((deployResult.exitCode ?? 1) !== 0) return deployResult.exitCode ?? 1;
|
|
@@ -1800,6 +1792,7 @@ const handleDeployCommand = async (argv, deps = {}) => {
|
|
|
1800
1792
|
backendAdapter,
|
|
1801
1793
|
migrationConfig,
|
|
1802
1794
|
targetArgs,
|
|
1795
|
+
env: deployCommandEnv,
|
|
1803
1796
|
context: "deploy",
|
|
1804
1797
|
direction: "up"
|
|
1805
1798
|
});
|
|
@@ -1810,6 +1803,7 @@ const handleDeployCommand = async (argv, deps = {}) => {
|
|
|
1810
1803
|
backfillConfig,
|
|
1811
1804
|
mode: "resume",
|
|
1812
1805
|
targetArgs,
|
|
1806
|
+
env: deployCommandEnv,
|
|
1813
1807
|
context: "deploy"
|
|
1814
1808
|
});
|
|
1815
1809
|
};
|
|
@@ -2470,16 +2464,6 @@ Options:
|
|
|
2470
2464
|
function assertNoVerifyLifecycleFlags(args) {
|
|
2471
2465
|
if (args.includes("--once") || args.includes("--bootstrap")) throw new Error("`kitcn verify` already runs one-shot runtime proof. Do not pass `--once` or `--bootstrap`.");
|
|
2472
2466
|
}
|
|
2473
|
-
async function withAnonymousVerifyAgentMode(run) {
|
|
2474
|
-
const previous = process.env.CONVEX_AGENT_MODE;
|
|
2475
|
-
if (!previous) process.env.CONVEX_AGENT_MODE = "anonymous";
|
|
2476
|
-
try {
|
|
2477
|
-
return await run();
|
|
2478
|
-
} finally {
|
|
2479
|
-
if (previous === void 0) delete process.env.CONVEX_AGENT_MODE;
|
|
2480
|
-
else process.env.CONVEX_AGENT_MODE = previous;
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
2467
|
function hasConfiguredLocalConvexDeployment(cwd = process.cwd()) {
|
|
2484
2468
|
return fs.existsSync(path.join(cwd, ".convex", "local", "default", "config.json"));
|
|
2485
2469
|
}
|
|
@@ -2524,7 +2508,7 @@ const handleVerifyCommand = async (argv, deps) => {
|
|
|
2524
2508
|
if (getAggregateBackfillDeploymentKey(extractBackendRunTargetArgs(backend, parsed.convexArgs)) !== "local") throw new Error("`kitcn verify` is local-only. Remove remote deployment flags like `--prod`, `--preview-name`, and `--deployment-name`.");
|
|
2525
2509
|
const devArgv = buildVerifyDevArgv(argv);
|
|
2526
2510
|
if (hasConfiguredLocalConvexDeployment()) return handleDevCommand(devArgv, deps);
|
|
2527
|
-
return withIsolatedLocalConvexState(() =>
|
|
2511
|
+
return withIsolatedLocalConvexState(() => handleDevCommand(devArgv, deps));
|
|
2528
2512
|
};
|
|
2529
2513
|
|
|
2530
2514
|
//#endregion
|
|
@@ -2654,6 +2638,15 @@ const LOCAL_NODE_REEXEC_COMMANDS = new Set([
|
|
|
2654
2638
|
"init",
|
|
2655
2639
|
"verify"
|
|
2656
2640
|
]);
|
|
2641
|
+
const DEPENDENCY_WARNING_COMMANDS = new Set([
|
|
2642
|
+
"add",
|
|
2643
|
+
"codegen",
|
|
2644
|
+
"deploy",
|
|
2645
|
+
"dev",
|
|
2646
|
+
"env",
|
|
2647
|
+
"init",
|
|
2648
|
+
"verify"
|
|
2649
|
+
]);
|
|
2657
2650
|
const COMMAND_HELP = {
|
|
2658
2651
|
init: INIT_HELP_TEXT,
|
|
2659
2652
|
add: ADD_HELP_TEXT,
|
|
@@ -2759,6 +2752,10 @@ const printCommandHelp = (command, backend = "convex") => {
|
|
|
2759
2752
|
}
|
|
2760
2753
|
printRootHelp(backend);
|
|
2761
2754
|
};
|
|
2755
|
+
function warnSupportedDependencyIssues(command) {
|
|
2756
|
+
if (!DEPENDENCY_WARNING_COMMANDS.has(command)) return;
|
|
2757
|
+
for (const warning of resolveSupportedDependencyWarnings()) logger.warn(`⚠️ kitcn expects ${warning.packageName} ${warning.minimum}; found ${warning.current}. Run \`bun add ${warning.installSpec}\` when you can.`);
|
|
2758
|
+
}
|
|
2762
2759
|
const handlePassthroughCommand = async (argv, deps) => {
|
|
2763
2760
|
const parsed = parseArgs(argv);
|
|
2764
2761
|
const { execa: execaFn, loadCliConfig, realConvex, realConcave } = resolveRunDeps(deps);
|
|
@@ -2811,6 +2808,7 @@ async function run(argv, deps) {
|
|
|
2811
2808
|
deps
|
|
2812
2809
|
});
|
|
2813
2810
|
if (reexecExitCode !== null) return reexecExitCode;
|
|
2811
|
+
warnSupportedDependencyIssues("dev");
|
|
2814
2812
|
return handleDevCommand(argv, deps);
|
|
2815
2813
|
}
|
|
2816
2814
|
if (VERSION_FLAGS.has(argv[0])) {
|
|
@@ -2846,7 +2844,9 @@ async function run(argv, deps) {
|
|
|
2846
2844
|
printCommandHelp(parsed.command, getBackend());
|
|
2847
2845
|
return 0;
|
|
2848
2846
|
}
|
|
2849
|
-
|
|
2847
|
+
const handler = COMMAND_HANDLERS[parsed.command] ?? handlePassthroughCommand;
|
|
2848
|
+
warnSupportedDependencyIssues(parsed.command);
|
|
2849
|
+
return handler(argv, deps);
|
|
2850
2850
|
}
|
|
2851
2851
|
if (isEntryPoint(process.argv[1], __filename)) {
|
|
2852
2852
|
process.on("SIGINT", () => process.exit(0));
|