kitcn 0.12.17 → 0.12.19
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/{api-entry-BckXqaLb.js → api-entry-BMCQSsCw.js} +6 -1
- package/dist/auth/client/index.js +82 -1
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +13 -13
- package/dist/auth/index.js +1 -1
- package/dist/auth/nextjs/index.d.ts +1 -1
- package/dist/auth/start/index.d.ts +7 -1
- package/dist/auth/start/index.js +37 -0
- package/dist/{auth-store-Cljlmdmi.js → auth-store-C0iMu34r.js} +53 -1
- package/dist/{backend-core-Rv9NorIW.mjs → backend-core-C0uwGXLx.mjs} +202 -167
- package/dist/{builder-CBdG5W6A.js → builder-Cb6gloDB.js} +161 -6
- package/dist/cli.mjs +1 -1
- package/dist/{context-utils-HPC5nXzx.d.ts → context-utils-BvWW0Ilq.d.ts} +8 -1
- package/dist/crpc/index.d.ts +2 -2
- package/dist/{generated-contract-disabled-Dzx2IRId.d.ts → generated-contract-disabled-UsFjh8jz.d.ts} +30 -30
- package/dist/{http-types-BS63Nsug.d.ts → http-types-BLFA9zS7.d.ts} +2 -1
- package/dist/{middleware-C2qTZ3V7.js → middleware-DkIhQXwg.js} +1 -1
- package/dist/{middleware-CU0mDiRs.d.ts → middleware-nS_qXecO.d.ts} +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-MWcxhQDv.js → procedure-caller-AjLfkHyF.js} +1 -1
- package/dist/{procedure-caller-C15h5Iel.d.ts → procedure-name-D-fDCBlo.d.ts} +33 -131
- package/dist/ratelimit/index.d.ts +2 -2
- package/dist/ratelimit/index.js +3 -3
- package/dist/react/index.js +7 -2
- package/dist/rsc/index.d.ts +3 -3
- package/dist/server/index.d.ts +5 -5
- package/dist/server/index.js +4 -4
- package/dist/{types-DrB2VeNb.d.ts → types-C6pQrnzD.d.ts} +1 -1
- package/dist/{types-BqUIoMfT.d.ts → types-a-RHmrDZ.d.ts} +9 -1
- package/dist/watcher.mjs +12 -9
- package/dist/{where-clause-compiler-DdjN63Io.d.ts → where-clause-compiler-CuH2JNxb.d.ts} +12 -12
- package/package.json +1 -1
- package/skills/convex/SKILL.md +8 -4
- package/skills/convex/references/features/auth-organizations.md +7 -2
- package/skills/convex/references/features/react.md +18 -3
|
@@ -2196,58 +2196,98 @@ const highlighter = {
|
|
|
2196
2196
|
};
|
|
2197
2197
|
|
|
2198
2198
|
//#endregion
|
|
2199
|
-
//#region src/cli/utils/
|
|
2200
|
-
const
|
|
2201
|
-
const JITI_EXPORT_CONDITION_PRIORITY = [
|
|
2202
|
-
"bun",
|
|
2203
|
-
"import",
|
|
2204
|
-
"module",
|
|
2205
|
-
"default",
|
|
2206
|
-
"require"
|
|
2207
|
-
];
|
|
2208
|
-
const SERVER_PARSER_SHIM_SOURCE = `const createMiddleware = (handler = undefined) => ({
|
|
2199
|
+
//#region src/cli/utils/crpc-builder-stub.ts
|
|
2200
|
+
const CRPC_BUILDER_STUB_SOURCE = `const createMiddleware = (handler = undefined) => ({
|
|
2209
2201
|
_handler: handler,
|
|
2210
|
-
pipe(nextHandler) {
|
|
2202
|
+
pipe(nextHandler = undefined) {
|
|
2211
2203
|
return createMiddleware(nextHandler);
|
|
2212
2204
|
},
|
|
2213
2205
|
});
|
|
2214
2206
|
|
|
2215
|
-
const
|
|
2207
|
+
const toMetaObject = (value = undefined) =>
|
|
2208
|
+
value && typeof value === "object" ? value : {};
|
|
2209
|
+
|
|
2210
|
+
const createProcedureExport = (type, state, handler) => ({
|
|
2211
|
+
_crpcMeta: {
|
|
2212
|
+
type,
|
|
2213
|
+
internal: state.internal ?? false,
|
|
2214
|
+
...toMetaObject(state.meta),
|
|
2215
|
+
},
|
|
2216
|
+
_handler: handler,
|
|
2217
|
+
});
|
|
2218
|
+
|
|
2219
|
+
const createProcedureBuilder = (state = {}) => {
|
|
2216
2220
|
const builder = {
|
|
2217
2221
|
internal() {
|
|
2218
|
-
return
|
|
2222
|
+
return createProcedureBuilder({ ...state, internal: true });
|
|
2219
2223
|
},
|
|
2220
2224
|
use() {
|
|
2221
|
-
return
|
|
2225
|
+
return createProcedureBuilder(state);
|
|
2222
2226
|
},
|
|
2223
|
-
meta() {
|
|
2224
|
-
return
|
|
2227
|
+
meta(value = undefined) {
|
|
2228
|
+
return createProcedureBuilder({
|
|
2229
|
+
...state,
|
|
2230
|
+
meta: {
|
|
2231
|
+
...toMetaObject(state.meta),
|
|
2232
|
+
...toMetaObject(value),
|
|
2233
|
+
},
|
|
2234
|
+
});
|
|
2225
2235
|
},
|
|
2226
2236
|
input() {
|
|
2227
|
-
return
|
|
2237
|
+
return createProcedureBuilder(state);
|
|
2238
|
+
},
|
|
2239
|
+
params() {
|
|
2240
|
+
return createProcedureBuilder(state);
|
|
2241
|
+
},
|
|
2242
|
+
searchParams() {
|
|
2243
|
+
return createProcedureBuilder(state);
|
|
2244
|
+
},
|
|
2245
|
+
paginated(options = undefined) {
|
|
2246
|
+
return createProcedureBuilder({
|
|
2247
|
+
...state,
|
|
2248
|
+
meta:
|
|
2249
|
+
typeof options?.limit === "number"
|
|
2250
|
+
? {
|
|
2251
|
+
...toMetaObject(state.meta),
|
|
2252
|
+
limit: options.limit,
|
|
2253
|
+
}
|
|
2254
|
+
: state.meta,
|
|
2255
|
+
});
|
|
2228
2256
|
},
|
|
2229
2257
|
output() {
|
|
2230
|
-
return
|
|
2258
|
+
return createProcedureBuilder(state);
|
|
2231
2259
|
},
|
|
2232
|
-
|
|
2233
|
-
return
|
|
2234
|
-
_crpcMeta: { type: "query" },
|
|
2235
|
-
_handler: handler,
|
|
2236
|
-
};
|
|
2260
|
+
form() {
|
|
2261
|
+
return createProcedureBuilder(state);
|
|
2237
2262
|
},
|
|
2238
|
-
|
|
2239
|
-
return
|
|
2240
|
-
_crpcMeta: { type: "mutation" },
|
|
2241
|
-
_handler: handler,
|
|
2242
|
-
};
|
|
2263
|
+
route() {
|
|
2264
|
+
return createProcedureBuilder(state);
|
|
2243
2265
|
},
|
|
2244
|
-
|
|
2245
|
-
return
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2266
|
+
get() {
|
|
2267
|
+
return createProcedureBuilder(state);
|
|
2268
|
+
},
|
|
2269
|
+
post() {
|
|
2270
|
+
return createProcedureBuilder(state);
|
|
2271
|
+
},
|
|
2272
|
+
put() {
|
|
2273
|
+
return createProcedureBuilder(state);
|
|
2274
|
+
},
|
|
2275
|
+
patch() {
|
|
2276
|
+
return createProcedureBuilder(state);
|
|
2277
|
+
},
|
|
2278
|
+
delete() {
|
|
2279
|
+
return createProcedureBuilder(state);
|
|
2280
|
+
},
|
|
2281
|
+
query(handler = undefined) {
|
|
2282
|
+
return createProcedureExport("query", state, handler);
|
|
2283
|
+
},
|
|
2284
|
+
mutation(handler = undefined) {
|
|
2285
|
+
return createProcedureExport("mutation", state, handler);
|
|
2286
|
+
},
|
|
2287
|
+
action(handler = undefined) {
|
|
2288
|
+
return createProcedureExport("action", state, handler);
|
|
2249
2289
|
},
|
|
2250
|
-
middleware(handler) {
|
|
2290
|
+
middleware(handler = undefined) {
|
|
2251
2291
|
return createMiddleware(handler);
|
|
2252
2292
|
},
|
|
2253
2293
|
};
|
|
@@ -2265,7 +2305,7 @@ export const initCRPC = {
|
|
|
2265
2305
|
context() {
|
|
2266
2306
|
return this;
|
|
2267
2307
|
},
|
|
2268
|
-
middleware(handler) {
|
|
2308
|
+
middleware(handler = undefined) {
|
|
2269
2309
|
return createMiddleware(handler);
|
|
2270
2310
|
},
|
|
2271
2311
|
create() {
|
|
@@ -2280,6 +2320,21 @@ export const initCRPC = {
|
|
|
2280
2320
|
},
|
|
2281
2321
|
};
|
|
2282
2322
|
|
|
2323
|
+
export const httpAction = createProcedureBuilder();
|
|
2324
|
+
`;
|
|
2325
|
+
|
|
2326
|
+
//#endregion
|
|
2327
|
+
//#region src/cli/utils/project-jiti.ts
|
|
2328
|
+
const require$2 = createRequire(import.meta.url);
|
|
2329
|
+
const JITI_EXPORT_CONDITION_PRIORITY = [
|
|
2330
|
+
"bun",
|
|
2331
|
+
"import",
|
|
2332
|
+
"module",
|
|
2333
|
+
"default",
|
|
2334
|
+
"require"
|
|
2335
|
+
];
|
|
2336
|
+
const SERVER_PARSER_SHIM_SOURCE = `${CRPC_BUILDER_STUB_SOURCE}
|
|
2337
|
+
|
|
2283
2338
|
export class CRPCError extends Error {
|
|
2284
2339
|
constructor(options = {}) {
|
|
2285
2340
|
super(options.message ?? options.code ?? "CRPC error");
|
|
@@ -2301,6 +2356,7 @@ export const createApiLeaf = (fnOrRoot, pathOrMeta, maybeMeta) => {
|
|
|
2301
2356
|
export const createGeneratedFunctionReference = (name) => ({
|
|
2302
2357
|
[Symbol.for("functionName")]: name,
|
|
2303
2358
|
});
|
|
2359
|
+
export const registerProcedureNameLookup = () => {};
|
|
2304
2360
|
export const typedProcedureResolver = (_functionRef, resolver) => resolver;
|
|
2305
2361
|
export const createGeneratedRegistryRuntime = () => ({
|
|
2306
2362
|
getCallerFactory() {
|
|
@@ -2388,6 +2444,7 @@ const buildTsconfigPathAliases = (cwd) => {
|
|
|
2388
2444
|
const getProjectServerParserShimPath = (cwd = process.cwd()) => ensureServerParserShim(cwd);
|
|
2389
2445
|
const createProjectJiti = (cwd = process.cwd()) => createJiti(cwd, {
|
|
2390
2446
|
interopDefault: true,
|
|
2447
|
+
jsx: { runtime: "automatic" },
|
|
2391
2448
|
moduleCache: false,
|
|
2392
2449
|
alias: {
|
|
2393
2450
|
...buildTsconfigPathAliases(cwd),
|
|
@@ -2423,10 +2480,10 @@ const ENTRY_POINT_EXTENSIONS = new Set([
|
|
|
2423
2480
|
const SCHEMA_RESOLVE_FILTER = /^\.{1,2}\/schema(\.ts|\.js)?$/;
|
|
2424
2481
|
const USE_NODE_DIRECTIVE_REGEX = /^\s*("|')use node\1;?\s*$/;
|
|
2425
2482
|
const VALID_IDENTIFIER_REGEX$2 = /^[a-zA-Z_$][\w$]*$/;
|
|
2426
|
-
const EXPORTED_CONST_CAPTURE_REGEX = /export\s+const\s+([a-zA-Z_$][\w$]*)\s*=/g;
|
|
2427
|
-
const CHAINED_PROCEDURE_CAPTURE_REGEX = /\.\s*(?:query|mutation|action)\s*\(/;
|
|
2428
|
-
const EXPORTED_NATIVE_HANDLER_CAPTURE_REGEX = /export\s+const\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:[\w$]+\.)?(?:query|mutation|action|internalQuery|internalMutation|internalAction)\s*\(/g;
|
|
2429
|
-
const EXPORTED_ORM_API_DESTRUCTURE_CAPTURE_REGEX = /export\s+const\s*\{([^}]+)\}\s*=\s*orm\.api\s*\(\s*\)\s*;?/g;
|
|
2483
|
+
const EXPORTED_CONST_CAPTURE_REGEX$1 = /export\s+const\s+([a-zA-Z_$][\w$]*)\s*=/g;
|
|
2484
|
+
const CHAINED_PROCEDURE_CAPTURE_REGEX$1 = /\.\s*(?:query|mutation|action)\s*\(/;
|
|
2485
|
+
const EXPORTED_NATIVE_HANDLER_CAPTURE_REGEX$1 = /export\s+const\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:[\w$]+\.)?(?:query|mutation|action|internalQuery|internalMutation|internalAction)\s*\(/g;
|
|
2486
|
+
const EXPORTED_ORM_API_DESTRUCTURE_CAPTURE_REGEX$1 = /export\s+const\s*\{([^}]+)\}\s*=\s*orm\.api\s*\(\s*\)\s*;?/g;
|
|
2430
2487
|
const supportsColor = isColorEnabled();
|
|
2431
2488
|
const isInteractiveTerminal = process.stdin.isTTY && process.stdout.isTTY;
|
|
2432
2489
|
let colorEnabled = supportsColor;
|
|
@@ -2590,17 +2647,17 @@ const isNodeEntryPoint = (entryPoint, functionsRoot) => {
|
|
|
2590
2647
|
};
|
|
2591
2648
|
const hasRuntimeProcedureType = (value) => value === "query" || value === "mutation" || value === "action";
|
|
2592
2649
|
const getNativeHandlerExportNames = (source) => {
|
|
2593
|
-
const exportNames = new Set(Array.from(source.matchAll(EXPORTED_NATIVE_HANDLER_CAPTURE_REGEX)).map((match) => match[1]).filter((name) => !!name));
|
|
2594
|
-
const exportConstMatches = Array.from(source.matchAll(EXPORTED_CONST_CAPTURE_REGEX));
|
|
2650
|
+
const exportNames = new Set(Array.from(source.matchAll(EXPORTED_NATIVE_HANDLER_CAPTURE_REGEX$1)).map((match) => match[1]).filter((name) => !!name));
|
|
2651
|
+
const exportConstMatches = Array.from(source.matchAll(EXPORTED_CONST_CAPTURE_REGEX$1));
|
|
2595
2652
|
for (const [index, match] of exportConstMatches.entries()) {
|
|
2596
2653
|
const exportName = match[1];
|
|
2597
2654
|
if (!exportName) continue;
|
|
2598
2655
|
const start = (match.index ?? 0) + match[0].length;
|
|
2599
2656
|
const end = exportConstMatches[index + 1]?.index ?? source.length;
|
|
2600
2657
|
const initializerSlice = source.slice(start, end);
|
|
2601
|
-
if (CHAINED_PROCEDURE_CAPTURE_REGEX.test(initializerSlice)) exportNames.add(exportName);
|
|
2658
|
+
if (CHAINED_PROCEDURE_CAPTURE_REGEX$1.test(initializerSlice)) exportNames.add(exportName);
|
|
2602
2659
|
}
|
|
2603
|
-
for (const match of source.matchAll(EXPORTED_ORM_API_DESTRUCTURE_CAPTURE_REGEX)) {
|
|
2660
|
+
for (const match of source.matchAll(EXPORTED_ORM_API_DESTRUCTURE_CAPTURE_REGEX$1)) {
|
|
2604
2661
|
const bindings = match[1];
|
|
2605
2662
|
for (const binding of bindings.split(",")) {
|
|
2606
2663
|
const trimmed = binding.trim();
|
|
@@ -3880,6 +3937,11 @@ const EXCLUDED_FILES = new Set([
|
|
|
3880
3937
|
"convex.config.ts",
|
|
3881
3938
|
"auth.config.ts"
|
|
3882
3939
|
]);
|
|
3940
|
+
const EXPORTED_CONST_CAPTURE_REGEX = /export\s+const\s+([a-zA-Z_$][\w$]*)\s*=/g;
|
|
3941
|
+
const CHAINED_PROCEDURE_CAPTURE_REGEX = /\.\s*(?:query|mutation|action)\s*\(/;
|
|
3942
|
+
const EXPORTED_NATIVE_HANDLER_CAPTURE_REGEX = /export\s+const\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:[\w$]+\.)?(?:query|mutation|action|internalQuery|internalMutation|internalAction)\s*\(/g;
|
|
3943
|
+
const EXPORTED_ORM_API_DESTRUCTURE_CAPTURE_REGEX = /export\s+const\s*\{([^}]+)\}\s*=\s*orm\.api\s*\(\s*\)\s*;?/g;
|
|
3944
|
+
const DIRECT_CODEGEN_META_CAPTURE_REGEX = /\b_crpc(?:Meta|HttpRoute)\b/;
|
|
3883
3945
|
/**
|
|
3884
3946
|
* Check if a file path should be included in meta generation.
|
|
3885
3947
|
* Filters out private files/directories (prefixed with _) and config files.
|
|
@@ -3896,6 +3958,20 @@ function isValidConvexFile(file) {
|
|
|
3896
3958
|
if (EXCLUDED_FILES.has(basename)) return false;
|
|
3897
3959
|
return true;
|
|
3898
3960
|
}
|
|
3961
|
+
function hasPotentialCodegenExports(source, filePath) {
|
|
3962
|
+
const normalizedFilePath = filePath?.replace(/\\/g, "/");
|
|
3963
|
+
if (normalizedFilePath === "http.ts" || normalizedFilePath?.endsWith("/http.ts")) return true;
|
|
3964
|
+
if (DIRECT_CODEGEN_META_CAPTURE_REGEX.test(source)) return true;
|
|
3965
|
+
if (Array.from(source.matchAll(EXPORTED_NATIVE_HANDLER_CAPTURE_REGEX)).length) return true;
|
|
3966
|
+
if (Array.from(source.matchAll(EXPORTED_ORM_API_DESTRUCTURE_CAPTURE_REGEX)).length) return true;
|
|
3967
|
+
const exportConstMatches = Array.from(source.matchAll(EXPORTED_CONST_CAPTURE_REGEX));
|
|
3968
|
+
for (const [index, match] of exportConstMatches.entries()) {
|
|
3969
|
+
const start = (match.index ?? 0) + match[0].length;
|
|
3970
|
+
const end = exportConstMatches[index + 1]?.index ?? source.length;
|
|
3971
|
+
if (CHAINED_PROCEDURE_CAPTURE_REGEX.test(source.slice(start, end))) return true;
|
|
3972
|
+
}
|
|
3973
|
+
return false;
|
|
3974
|
+
}
|
|
3899
3975
|
|
|
3900
3976
|
//#endregion
|
|
3901
3977
|
//#region src/cli/utils/logger.ts
|
|
@@ -4089,6 +4165,47 @@ function normalizeImportPath(value) {
|
|
|
4089
4165
|
function escapeRegex$1(value) {
|
|
4090
4166
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4091
4167
|
}
|
|
4168
|
+
function getIndexLineColumn(source, index) {
|
|
4169
|
+
const lines = source.slice(0, index).split("\n");
|
|
4170
|
+
return {
|
|
4171
|
+
column: (lines.at(-1)?.length ?? 0) + 1,
|
|
4172
|
+
line: lines.length
|
|
4173
|
+
};
|
|
4174
|
+
}
|
|
4175
|
+
function findProcedureCallIndex(params) {
|
|
4176
|
+
const exportMatch = (params.exportName === "default" ? /\bexport\s+default\b/g : new RegExp(`\\bexport\\s+const\\s+${escapeRegex$1(params.exportName)}\\s*=`, "g")).exec(params.source);
|
|
4177
|
+
if (!exportMatch) return;
|
|
4178
|
+
const tail = params.source.slice(exportMatch.index);
|
|
4179
|
+
const callMatch = new RegExp(`\\.\\s*${params.type}\\s*\\(`, "g").exec(tail);
|
|
4180
|
+
if (!callMatch || callMatch.index < 0) return;
|
|
4181
|
+
return exportMatch.index + callMatch.index;
|
|
4182
|
+
}
|
|
4183
|
+
function buildProcedureNameLookupEntries(params) {
|
|
4184
|
+
if (params.procedures.length === 0) return [];
|
|
4185
|
+
const source = fs.readFileSync(params.filePath, "utf8");
|
|
4186
|
+
return params.procedures.flatMap((procedure) => {
|
|
4187
|
+
const callIndex = findProcedureCallIndex({
|
|
4188
|
+
exportName: procedure.exportName,
|
|
4189
|
+
source,
|
|
4190
|
+
type: procedure.type
|
|
4191
|
+
});
|
|
4192
|
+
if (callIndex === void 0) return [];
|
|
4193
|
+
const location = getIndexLineColumn(source, callIndex);
|
|
4194
|
+
return [{
|
|
4195
|
+
column: location.column,
|
|
4196
|
+
line: location.line,
|
|
4197
|
+
name: `${params.moduleName}:${procedure.exportName}`
|
|
4198
|
+
}];
|
|
4199
|
+
});
|
|
4200
|
+
}
|
|
4201
|
+
function emitProcedureNameLookupLiteral(lookup) {
|
|
4202
|
+
const entries = Object.entries(lookup);
|
|
4203
|
+
if (entries.length === 0) return "{}";
|
|
4204
|
+
return `{\n${entries.map(([file, locations]) => {
|
|
4205
|
+
const items = locations.map((location) => `{ column: ${location.column}, line: ${location.line}, name: ${JSON.stringify(location.name)} }`).join(", ");
|
|
4206
|
+
return ` ${JSON.stringify(file)}: [${items}],`;
|
|
4207
|
+
}).join("\n")}\n}`;
|
|
4208
|
+
}
|
|
4092
4209
|
function formatKey(key) {
|
|
4093
4210
|
return VALID_IDENTIFIER_RE.test(key) ? key : `'${key}'`;
|
|
4094
4211
|
}
|
|
@@ -4247,12 +4364,17 @@ function getGeneratedRuntimeOutputFile(functionsDir, moduleName) {
|
|
|
4247
4364
|
const runtimeModuleName = moduleName.startsWith(`${GENERATED_DIR}/`) ? moduleName.slice(10) : moduleName;
|
|
4248
4365
|
return path.join(functionsDir, GENERATED_DIR, `${runtimeModuleName}.runtime.ts`);
|
|
4249
4366
|
}
|
|
4250
|
-
function emitGeneratedServerPlaceholderFile() {
|
|
4251
|
-
|
|
4367
|
+
function emitGeneratedServerPlaceholderFile(functionsDir) {
|
|
4368
|
+
const functionsDirHint = normalizeImportPath(path.relative(process.cwd(), functionsDir)) || "convex";
|
|
4369
|
+
return `// @ts-nocheck
|
|
4370
|
+
// biome-ignore-all format: generated
|
|
4252
4371
|
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
|
|
4253
4372
|
// This file is auto-generated by kitcn
|
|
4254
4373
|
// Do not edit manually. Run \`kitcn codegen\` to regenerate.
|
|
4255
4374
|
|
|
4375
|
+
import {
|
|
4376
|
+
registerProcedureNameLookup,
|
|
4377
|
+
} from 'kitcn/server';
|
|
4256
4378
|
import type {
|
|
4257
4379
|
ActionCtx as ServerActionCtx,
|
|
4258
4380
|
MutationCtx as ServerMutationCtx,
|
|
@@ -4264,72 +4386,9 @@ export type MutationCtx = ServerMutationCtx;
|
|
|
4264
4386
|
export type ActionCtx = ServerActionCtx;
|
|
4265
4387
|
export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
|
|
4266
4388
|
|
|
4267
|
-
|
|
4268
|
-
_handler: handler,
|
|
4269
|
-
pipe(nextHandler?: unknown) {
|
|
4270
|
-
return createMiddleware(nextHandler);
|
|
4271
|
-
},
|
|
4272
|
-
});
|
|
4273
|
-
|
|
4274
|
-
const createProcedureBuilder = () => {
|
|
4275
|
-
const builder = {
|
|
4276
|
-
internal() {
|
|
4277
|
-
return builder;
|
|
4278
|
-
},
|
|
4279
|
-
use() {
|
|
4280
|
-
return builder;
|
|
4281
|
-
},
|
|
4282
|
-
meta() {
|
|
4283
|
-
return builder;
|
|
4284
|
-
},
|
|
4285
|
-
input() {
|
|
4286
|
-
return builder;
|
|
4287
|
-
},
|
|
4288
|
-
output() {
|
|
4289
|
-
return builder;
|
|
4290
|
-
},
|
|
4291
|
-
query(handler?: unknown) {
|
|
4292
|
-
return handler ?? builder;
|
|
4293
|
-
},
|
|
4294
|
-
mutation(handler?: unknown) {
|
|
4295
|
-
return handler ?? builder;
|
|
4296
|
-
},
|
|
4297
|
-
action(handler?: unknown) {
|
|
4298
|
-
return handler ?? builder;
|
|
4299
|
-
},
|
|
4300
|
-
middleware(handler?: unknown) {
|
|
4301
|
-
return createMiddleware(handler);
|
|
4302
|
-
},
|
|
4303
|
-
};
|
|
4304
|
-
|
|
4305
|
-
return builder;
|
|
4306
|
-
};
|
|
4389
|
+
${CRPC_BUILDER_STUB_SOURCE}
|
|
4307
4390
|
|
|
4308
|
-
|
|
4309
|
-
meta() {
|
|
4310
|
-
return this;
|
|
4311
|
-
},
|
|
4312
|
-
dataModel() {
|
|
4313
|
-
return this;
|
|
4314
|
-
},
|
|
4315
|
-
context() {
|
|
4316
|
-
return this;
|
|
4317
|
-
},
|
|
4318
|
-
middleware(handler?: unknown) {
|
|
4319
|
-
return createMiddleware(handler);
|
|
4320
|
-
},
|
|
4321
|
-
create() {
|
|
4322
|
-
return {
|
|
4323
|
-
query: createProcedureBuilder(),
|
|
4324
|
-
mutation: createProcedureBuilder(),
|
|
4325
|
-
action: createProcedureBuilder(),
|
|
4326
|
-
httpAction: createProcedureBuilder(),
|
|
4327
|
-
middleware: createMiddleware,
|
|
4328
|
-
router: (record = {}) => record,
|
|
4329
|
-
};
|
|
4330
|
-
},
|
|
4331
|
-
};
|
|
4332
|
-
export const httpAction = createProcedureBuilder();
|
|
4391
|
+
registerProcedureNameLookup({}, ${JSON.stringify(functionsDirHint)});
|
|
4333
4392
|
|
|
4334
4393
|
export function withOrm<Ctx>(ctx: Ctx): Ctx {
|
|
4335
4394
|
return ctx;
|
|
@@ -4377,7 +4436,7 @@ function ensureGeneratedSupportPlaceholders(functionsDir, options) {
|
|
|
4377
4436
|
fs.mkdirSync(generatedDir, { recursive: true });
|
|
4378
4437
|
const includeAuth = options?.includeAuth ?? true;
|
|
4379
4438
|
if (!fs.existsSync(serverOutputFile)) {
|
|
4380
|
-
writeFileIfChanged(serverOutputFile, emitGeneratedServerPlaceholderFile());
|
|
4439
|
+
writeFileIfChanged(serverOutputFile, emitGeneratedServerPlaceholderFile(functionsDir));
|
|
4381
4440
|
createdPlaceholderFiles.push(serverOutputFile);
|
|
4382
4441
|
}
|
|
4383
4442
|
if (includeAuth && !fs.existsSync(authOutputFile)) {
|
|
@@ -4458,7 +4517,7 @@ function cleanupGeneratedPluginArtifacts(functionsDir) {
|
|
|
4458
4517
|
force: true
|
|
4459
4518
|
});
|
|
4460
4519
|
}
|
|
4461
|
-
function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasMigrationsManifest) {
|
|
4520
|
+
function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasMigrationsManifest, procedureNameLookup) {
|
|
4462
4521
|
const asSingleQuotedImport = (importPath) => `'${importPath.replaceAll("'", "\\'")}'`;
|
|
4463
4522
|
const serverTypesImportPath = getServerTypesImportPath(outputFile, functionsDir);
|
|
4464
4523
|
const dataModelImportPath = getDataModelImportPath(outputFile, functionsDir);
|
|
@@ -4470,11 +4529,16 @@ function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasMigr
|
|
|
4470
4529
|
const migrationsManifestImportLiteral = asSingleQuotedImport(migrationsManifestImportPath);
|
|
4471
4530
|
const migrationsImportLine = hasMigrationsManifest ? `import { migrations } from ${migrationsManifestImportLiteral};\n` : "";
|
|
4472
4531
|
const migrationsConfigLine = hasMigrationsManifest ? " migrations,\n" : "";
|
|
4532
|
+
const functionsDirHint = normalizeImportPath(path.relative(process.cwd(), functionsDir)) || "convex";
|
|
4533
|
+
const procedureNameLookupLiteral = emitProcedureNameLookupLiteral(procedureNameLookup);
|
|
4473
4534
|
if (!hasOrmSchema) return `// biome-ignore-all format: generated
|
|
4474
4535
|
// This file is auto-generated by kitcn
|
|
4475
4536
|
// Do not edit manually. Run \`kitcn codegen\` to regenerate.
|
|
4476
4537
|
|
|
4477
|
-
import {
|
|
4538
|
+
import {
|
|
4539
|
+
initCRPC as baseInitCRPC,
|
|
4540
|
+
registerProcedureNameLookup,
|
|
4541
|
+
} from 'kitcn/server';
|
|
4478
4542
|
import type { DataModel } from ${dataModelImportLiteral};
|
|
4479
4543
|
import type {
|
|
4480
4544
|
ActionCtx as ServerActionCtx,
|
|
@@ -4489,6 +4553,11 @@ export type ActionCtx = ServerActionCtx;
|
|
|
4489
4553
|
export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
|
|
4490
4554
|
export type OrmCtx<Ctx = QueryCtx> = Ctx;
|
|
4491
4555
|
|
|
4556
|
+
registerProcedureNameLookup(
|
|
4557
|
+
${procedureNameLookupLiteral},
|
|
4558
|
+
${JSON.stringify(functionsDirHint)}
|
|
4559
|
+
);
|
|
4560
|
+
|
|
4492
4561
|
export function withOrm<Ctx extends ServerQueryCtx | ServerMutationCtx>(ctx: Ctx): OrmCtx<Ctx> {
|
|
4493
4562
|
return ctx as OrmCtx<Ctx>;
|
|
4494
4563
|
}
|
|
@@ -4513,6 +4582,7 @@ import {
|
|
|
4513
4582
|
import {
|
|
4514
4583
|
createGeneratedFunctionReference,
|
|
4515
4584
|
initCRPC as baseInitCRPC,
|
|
4585
|
+
registerProcedureNameLookup,
|
|
4516
4586
|
} from 'kitcn/server';
|
|
4517
4587
|
import type { DataModel } from ${dataModelImportLiteral};
|
|
4518
4588
|
import type {
|
|
@@ -4533,6 +4603,11 @@ ${`const ormFunctions: OrmFunctions = {
|
|
|
4533
4603
|
};`}
|
|
4534
4604
|
const ormSchema = schema;
|
|
4535
4605
|
|
|
4606
|
+
registerProcedureNameLookup(
|
|
4607
|
+
${procedureNameLookupLiteral},
|
|
4608
|
+
${JSON.stringify(functionsDirHint)}
|
|
4609
|
+
);
|
|
4610
|
+
|
|
4536
4611
|
export const orm = createOrm({
|
|
4537
4612
|
schema: ormSchema,
|
|
4538
4613
|
ormFunctions,
|
|
@@ -5046,6 +5121,7 @@ async function generateMeta(sharedDir, options) {
|
|
|
5046
5121
|
const meta = {};
|
|
5047
5122
|
const allHttpRoutes = {};
|
|
5048
5123
|
const procedureEntries = [];
|
|
5124
|
+
const procedureNameLookup = {};
|
|
5049
5125
|
const fatalParseFailures = [];
|
|
5050
5126
|
let createdRuntimePlaceholders = [];
|
|
5051
5127
|
let createdSupportPlaceholders = [];
|
|
@@ -5074,6 +5150,7 @@ async function generateMeta(sharedDir, options) {
|
|
|
5074
5150
|
try {
|
|
5075
5151
|
const jitiInstance = createProjectJiti();
|
|
5076
5152
|
const files = listFilesRecursive(functionsDir).filter((file) => file.endsWith(".ts") && isValidConvexFile(file));
|
|
5153
|
+
const parseCandidateFiles = files.filter((file) => hasPotentialCodegenExports(fs.readFileSync(path.join(functionsDir, file), "utf8"), file));
|
|
5077
5154
|
const existingRuntimeFilesBeforeParse = new Set(listGeneratedRuntimeFiles(functionsDir));
|
|
5078
5155
|
const runtimePlaceholderModules = [...new Set([
|
|
5079
5156
|
...files.map((file) => file.replace(TS_EXTENSION_RE$2, "")),
|
|
@@ -5081,7 +5158,7 @@ async function generateMeta(sharedDir, options) {
|
|
|
5081
5158
|
...generateAuth ? [generatedAuthModuleName] : []
|
|
5082
5159
|
])];
|
|
5083
5160
|
createdRuntimePlaceholders = ensureGeneratedRuntimePlaceholders(functionsDir, runtimePlaceholderModules, resolveModuleRuntimeExportNames(runtimePlaceholderModules, normalizedTrimSegments));
|
|
5084
|
-
for (const file of
|
|
5161
|
+
for (const file of parseCandidateFiles) {
|
|
5085
5162
|
const filePath = path.join(functionsDir, file);
|
|
5086
5163
|
const moduleName = file.replace(TS_EXTENSION_RE$2, "");
|
|
5087
5164
|
try {
|
|
@@ -5101,6 +5178,13 @@ async function generateMeta(sharedDir, options) {
|
|
|
5101
5178
|
type: procedure.type,
|
|
5102
5179
|
kind: "crpc"
|
|
5103
5180
|
});
|
|
5181
|
+
const procedureNameEntries = buildProcedureNameLookupEntries({
|
|
5182
|
+
file,
|
|
5183
|
+
filePath,
|
|
5184
|
+
moduleName,
|
|
5185
|
+
procedures
|
|
5186
|
+
});
|
|
5187
|
+
if (procedureNameEntries.length > 0) procedureNameLookup[file] = procedureNameEntries;
|
|
5104
5188
|
} catch (error) {
|
|
5105
5189
|
const runtimeFile = getGeneratedRuntimeOutputFile(functionsDir, moduleName);
|
|
5106
5190
|
if (existingRuntimeFilesBeforeParse.has(runtimeFile)) runtimeFilesPreservedFromParseFailures.add(runtimeFile);
|
|
@@ -5181,7 +5265,7 @@ ${optionalTypeExports}
|
|
|
5181
5265
|
if (!fs.existsSync(outputDirname)) fs.mkdirSync(outputDirname, { recursive: true });
|
|
5182
5266
|
writeFileIfChanged(outputFile, output);
|
|
5183
5267
|
} else fs.rmSync(outputFile, { force: true });
|
|
5184
|
-
const serverOutput = emitGeneratedServerFile(serverOutputFile, functionsDir, hasOrmSchema, hasMigrationsManifest);
|
|
5268
|
+
const serverOutput = emitGeneratedServerFile(serverOutputFile, functionsDir, hasOrmSchema, hasMigrationsManifest, procedureNameLookup);
|
|
5185
5269
|
const generatedOutputDirname = path.dirname(serverOutputFile);
|
|
5186
5270
|
if (!fs.existsSync(generatedOutputDirname)) fs.mkdirSync(generatedOutputDirname, { recursive: true });
|
|
5187
5271
|
writeFileIfChanged(serverOutputFile, serverOutput);
|
|
@@ -12351,7 +12435,8 @@ const AGGREGATE_STATE_VERSION = 1;
|
|
|
12351
12435
|
const INIT_SHADCN_PACKAGE_SPEC = "shadcn@4.0.1";
|
|
12352
12436
|
const INIT_LOCAL_BOOTSTRAP_TIMEOUT_MS = 3e4;
|
|
12353
12437
|
const LOCAL_BACKEND_NOT_RUNNING_RE = /Local backend isn't running/i;
|
|
12354
|
-
const INIT_GENERATED_SERVER_STUB_TEMPLATE =
|
|
12438
|
+
const INIT_GENERATED_SERVER_STUB_TEMPLATE = `// @ts-nocheck
|
|
12439
|
+
import type {
|
|
12355
12440
|
GenericActionCtx,
|
|
12356
12441
|
GenericDataModel,
|
|
12357
12442
|
GenericMutationCtx,
|
|
@@ -12363,57 +12448,7 @@ export type MutationCtx = GenericMutationCtx<GenericDataModel>;
|
|
|
12363
12448
|
export type ActionCtx = GenericActionCtx<GenericDataModel>;
|
|
12364
12449
|
export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
|
|
12365
12450
|
|
|
12366
|
-
|
|
12367
|
-
const builder = {
|
|
12368
|
-
internal() {
|
|
12369
|
-
return builder;
|
|
12370
|
-
},
|
|
12371
|
-
use() {
|
|
12372
|
-
return builder;
|
|
12373
|
-
},
|
|
12374
|
-
meta() {
|
|
12375
|
-
return builder;
|
|
12376
|
-
},
|
|
12377
|
-
input() {
|
|
12378
|
-
return builder;
|
|
12379
|
-
},
|
|
12380
|
-
output() {
|
|
12381
|
-
return builder;
|
|
12382
|
-
},
|
|
12383
|
-
query(handler?: unknown) {
|
|
12384
|
-
return handler ?? builder;
|
|
12385
|
-
},
|
|
12386
|
-
mutation(handler?: unknown) {
|
|
12387
|
-
return handler ?? builder;
|
|
12388
|
-
},
|
|
12389
|
-
action(handler?: unknown) {
|
|
12390
|
-
return handler ?? builder;
|
|
12391
|
-
},
|
|
12392
|
-
};
|
|
12393
|
-
|
|
12394
|
-
return builder;
|
|
12395
|
-
};
|
|
12396
|
-
|
|
12397
|
-
export const initCRPC = {
|
|
12398
|
-
meta() {
|
|
12399
|
-
return this;
|
|
12400
|
-
},
|
|
12401
|
-
dataModel() {
|
|
12402
|
-
return this;
|
|
12403
|
-
},
|
|
12404
|
-
context() {
|
|
12405
|
-
return this;
|
|
12406
|
-
},
|
|
12407
|
-
create() {
|
|
12408
|
-
return {
|
|
12409
|
-
query: createProcedureBuilder(),
|
|
12410
|
-
mutation: createProcedureBuilder(),
|
|
12411
|
-
action: createProcedureBuilder(),
|
|
12412
|
-
httpAction: createProcedureBuilder(),
|
|
12413
|
-
router: (record = {}) => record,
|
|
12414
|
-
};
|
|
12415
|
-
},
|
|
12416
|
-
};
|
|
12451
|
+
${CRPC_BUILDER_STUB_SOURCE}
|
|
12417
12452
|
`;
|
|
12418
12453
|
const INIT_LOCAL_BOOTSTRAP_READY_RE = /(Convex|Concave) functions ready!/i;
|
|
12419
12454
|
const CONVEX_INIT_CREATED_CONFIG_RE = /Configured a local deployment|Provisioned a .* deployment|saved its name as CONVEX_DEPLOYMENT/i;
|