kitcn 0.12.18 → 0.12.20

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 (32) hide show
  1. package/dist/aggregate/index.d.ts +1 -1
  2. package/dist/{api-entry-BckXqaLb.js → api-entry-BUAh_K4k.js} +10 -2
  3. package/dist/auth/generated/index.d.ts +1 -1
  4. package/dist/auth/index.d.ts +2 -2
  5. package/dist/auth/index.js +1 -1
  6. package/dist/auth/nextjs/index.d.ts +1 -1
  7. package/dist/{backend-core-CGjsBIOp.mjs → backend-core-C0uwGXLx.mjs} +107 -14
  8. package/dist/{builder-Bh18Y2t0.js → builder-Cb6gloDB.js} +160 -6
  9. package/dist/cli.mjs +1 -1
  10. package/dist/{context-utils-HPC5nXzx.d.ts → context-utils-BvWW0Ilq.d.ts} +8 -1
  11. package/dist/crpc/index.d.ts +2 -2
  12. package/dist/{generated-contract-disabled-Dzx2IRId.d.ts → generated-contract-disabled-21YxPk5W.d.ts} +1 -1
  13. package/dist/{http-types-BS63Nsug.d.ts → http-types-BLFA9zS7.d.ts} +2 -1
  14. package/dist/{middleware-C5P1Q29c.js → middleware-DkIhQXwg.js} +1 -1
  15. package/dist/{middleware-CU0mDiRs.d.ts → middleware-nS_qXecO.d.ts} +1 -1
  16. package/dist/orm/index.d.ts +1 -1
  17. package/dist/plugins/index.d.ts +1 -1
  18. package/dist/plugins/index.js +1 -1
  19. package/dist/{procedure-caller-DL0Ubgky.js → procedure-caller-AjLfkHyF.js} +1 -1
  20. package/dist/{procedure-caller-DloN1DNv.d.ts → procedure-name-D-fDCBlo.d.ts} +28 -128
  21. package/dist/ratelimit/index.d.ts +2 -2
  22. package/dist/ratelimit/index.js +3 -3
  23. package/dist/rsc/index.d.ts +3 -3
  24. package/dist/server/index.d.ts +5 -5
  25. package/dist/server/index.js +4 -4
  26. package/dist/{types-DrB2VeNb.d.ts → types-C6pQrnzD.d.ts} +1 -1
  27. package/dist/{types-BqUIoMfT.d.ts → types-a-RHmrDZ.d.ts} +9 -1
  28. package/dist/watcher.mjs +12 -9
  29. package/dist/{where-clause-compiler-Dw3EVdi6.d.ts → where-clause-compiler-DdjN63Io.d.ts} +23 -23
  30. package/package.json +1 -1
  31. package/skills/convex/SKILL.md +8 -5
  32. package/skills/convex/references/features/auth-organizations.md +7 -2
@@ -1,4 +1,4 @@
1
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-Dw3EVdi6.js";
1
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-DdjN63Io.js";
2
2
  import * as convex_values0 from "convex/values";
3
3
  import { GenericId, Infer, Value } from "convex/values";
4
4
  import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
@@ -5,6 +5,7 @@ const isQueryCtx = (ctx) => "db" in ctx;
5
5
  const isMutationCtx = (ctx) => "db" in ctx && "scheduler" in ctx;
6
6
  const isActionCtx = (ctx) => "runAction" in ctx;
7
7
  const isRunMutationCtx = (ctx) => "runMutation" in ctx;
8
+ const isSchedulerCtx = (ctx) => "scheduler" in ctx && typeof ctx.scheduler === "object" && ctx.scheduler !== null;
8
9
  const requireQueryCtx = (ctx) => {
9
10
  if (!isQueryCtx(ctx)) throw new Error("Query context required");
10
11
  return ctx;
@@ -14,13 +15,20 @@ const requireMutationCtx = (ctx) => {
14
15
  return ctx;
15
16
  };
16
17
  const requireActionCtx = (ctx) => {
17
- if (!isActionCtx(ctx)) throw new Error("Action context required");
18
+ if (!isActionCtx(ctx)) {
19
+ if (isSchedulerCtx(ctx)) throw new Error("Action context required. This ctx can schedule work but cannot call action procedures directly. Use requireSchedulerCtx(ctx) with caller.schedule.*.");
20
+ throw new Error("Action context required");
21
+ }
18
22
  return ctx;
19
23
  };
20
24
  const requireRunMutationCtx = (ctx) => {
21
25
  if (!isRunMutationCtx(ctx)) throw new Error("Mutation or action context required");
22
26
  return ctx;
23
27
  };
28
+ const requireSchedulerCtx = (ctx) => {
29
+ if (!isSchedulerCtx(ctx)) throw new Error("Mutation or action context with scheduler required");
30
+ return ctx;
31
+ };
24
32
 
25
33
  //#endregion
26
34
  //#region src/server/api-entry.ts
@@ -63,4 +71,4 @@ function createGeneratedFunctionReference(name) {
63
71
  }
64
72
 
65
73
  //#endregion
66
- export { isMutationCtx as a, requireActionCtx as c, requireRunMutationCtx as d, isActionCtx as i, requireMutationCtx as l, createGeneratedFunctionReference as n, isQueryCtx as o, getGeneratedValue as r, isRunMutationCtx as s, createApiLeaf as t, requireQueryCtx as u };
74
+ export { isMutationCtx as a, isSchedulerCtx as c, requireQueryCtx as d, requireRunMutationCtx as f, isActionCtx as i, requireActionCtx as l, createGeneratedFunctionReference as n, isQueryCtx as o, requireSchedulerCtx as p, getGeneratedValue as r, isRunMutationCtx as s, createApiLeaf as t, requireMutationCtx as u };
@@ -1,2 +1,2 @@
1
- import { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-Dzx2IRId.js";
1
+ import { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-21YxPk5W.js";
2
2
  export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
@@ -1,7 +1,7 @@
1
1
  import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-CFZqIvD7.js";
2
2
  import { t as GetAuth } from "../types-BiJE7qxR.js";
3
- import { t as GenericCtx } from "../context-utils-HPC5nXzx.js";
4
- import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-Dzx2IRId.js";
3
+ import { t as GenericCtx } from "../context-utils-BvWW0Ilq.js";
4
+ import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-21YxPk5W.js";
5
5
  import * as convex_values0 from "convex/values";
6
6
  import { Infer } from "convex/values";
7
7
  import { DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
@@ -1,6 +1,6 @@
1
1
  import { r as partial, s as asyncMap } from "../validators-B7oIJCAp.js";
2
2
  import { i as defineAuth, n as createDisabledAuthRuntime, r as getGeneratedAuthDisabledReason, t as DEFAULT_AUTH_DEFINITION_PATH } from "../generated-contract-disabled-Cih4eITO.js";
3
- import { n as createGeneratedFunctionReference, o as isQueryCtx, s as isRunMutationCtx } from "../api-entry-BckXqaLb.js";
3
+ import { n as createGeneratedFunctionReference, o as isQueryCtx, s as isRunMutationCtx } from "../api-entry-BUAh_K4k.js";
4
4
  import { n as customCtx, r as customMutation } from "../customFunctions-C0voKmtx.js";
5
5
  import { a as mergedStream, l as unsetToken, o as stream, t as getByIdWithOrmQueryFallback, v as eq } from "../query-context-B8o6-8kC.js";
6
6
  import { v } from "convex/values";
@@ -1,4 +1,4 @@
1
- import { L as ConvexContext, z as LazyCaller } from "../../procedure-caller-DloN1DNv.js";
1
+ import { U as LazyCaller, V as ConvexContext } from "../../procedure-name-D-fDCBlo.js";
2
2
  import { GetTokenOptions } from "@convex-dev/better-auth/utils";
3
3
 
4
4
  //#region src/auth-nextjs/index.d.ts
@@ -2356,6 +2356,7 @@ export const createApiLeaf = (fnOrRoot, pathOrMeta, maybeMeta) => {
2356
2356
  export const createGeneratedFunctionReference = (name) => ({
2357
2357
  [Symbol.for("functionName")]: name,
2358
2358
  });
2359
+ export const registerProcedureNameLookup = () => {};
2359
2360
  export const typedProcedureResolver = (_functionRef, resolver) => resolver;
2360
2361
  export const createGeneratedRegistryRuntime = () => ({
2361
2362
  getCallerFactory() {
@@ -2443,6 +2444,7 @@ const buildTsconfigPathAliases = (cwd) => {
2443
2444
  const getProjectServerParserShimPath = (cwd = process.cwd()) => ensureServerParserShim(cwd);
2444
2445
  const createProjectJiti = (cwd = process.cwd()) => createJiti(cwd, {
2445
2446
  interopDefault: true,
2447
+ jsx: { runtime: "automatic" },
2446
2448
  moduleCache: false,
2447
2449
  alias: {
2448
2450
  ...buildTsconfigPathAliases(cwd),
@@ -2478,10 +2480,10 @@ const ENTRY_POINT_EXTENSIONS = new Set([
2478
2480
  const SCHEMA_RESOLVE_FILTER = /^\.{1,2}\/schema(\.ts|\.js)?$/;
2479
2481
  const USE_NODE_DIRECTIVE_REGEX = /^\s*("|')use node\1;?\s*$/;
2480
2482
  const VALID_IDENTIFIER_REGEX$2 = /^[a-zA-Z_$][\w$]*$/;
2481
- const EXPORTED_CONST_CAPTURE_REGEX = /export\s+const\s+([a-zA-Z_$][\w$]*)\s*=/g;
2482
- const CHAINED_PROCEDURE_CAPTURE_REGEX = /\.\s*(?:query|mutation|action)\s*\(/;
2483
- 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;
2484
- 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;
2485
2487
  const supportsColor = isColorEnabled();
2486
2488
  const isInteractiveTerminal = process.stdin.isTTY && process.stdout.isTTY;
2487
2489
  let colorEnabled = supportsColor;
@@ -2645,17 +2647,17 @@ const isNodeEntryPoint = (entryPoint, functionsRoot) => {
2645
2647
  };
2646
2648
  const hasRuntimeProcedureType = (value) => value === "query" || value === "mutation" || value === "action";
2647
2649
  const getNativeHandlerExportNames = (source) => {
2648
- const exportNames = new Set(Array.from(source.matchAll(EXPORTED_NATIVE_HANDLER_CAPTURE_REGEX)).map((match) => match[1]).filter((name) => !!name));
2649
- 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));
2650
2652
  for (const [index, match] of exportConstMatches.entries()) {
2651
2653
  const exportName = match[1];
2652
2654
  if (!exportName) continue;
2653
2655
  const start = (match.index ?? 0) + match[0].length;
2654
2656
  const end = exportConstMatches[index + 1]?.index ?? source.length;
2655
2657
  const initializerSlice = source.slice(start, end);
2656
- if (CHAINED_PROCEDURE_CAPTURE_REGEX.test(initializerSlice)) exportNames.add(exportName);
2658
+ if (CHAINED_PROCEDURE_CAPTURE_REGEX$1.test(initializerSlice)) exportNames.add(exportName);
2657
2659
  }
2658
- 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)) {
2659
2661
  const bindings = match[1];
2660
2662
  for (const binding of bindings.split(",")) {
2661
2663
  const trimmed = binding.trim();
@@ -3935,6 +3937,11 @@ const EXCLUDED_FILES = new Set([
3935
3937
  "convex.config.ts",
3936
3938
  "auth.config.ts"
3937
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/;
3938
3945
  /**
3939
3946
  * Check if a file path should be included in meta generation.
3940
3947
  * Filters out private files/directories (prefixed with _) and config files.
@@ -3951,6 +3958,20 @@ function isValidConvexFile(file) {
3951
3958
  if (EXCLUDED_FILES.has(basename)) return false;
3952
3959
  return true;
3953
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
+ }
3954
3975
 
3955
3976
  //#endregion
3956
3977
  //#region src/cli/utils/logger.ts
@@ -4144,6 +4165,47 @@ function normalizeImportPath(value) {
4144
4165
  function escapeRegex$1(value) {
4145
4166
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4146
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
+ }
4147
4209
  function formatKey(key) {
4148
4210
  return VALID_IDENTIFIER_RE.test(key) ? key : `'${key}'`;
4149
4211
  }
@@ -4302,13 +4364,17 @@ function getGeneratedRuntimeOutputFile(functionsDir, moduleName) {
4302
4364
  const runtimeModuleName = moduleName.startsWith(`${GENERATED_DIR}/`) ? moduleName.slice(10) : moduleName;
4303
4365
  return path.join(functionsDir, GENERATED_DIR, `${runtimeModuleName}.runtime.ts`);
4304
4366
  }
4305
- function emitGeneratedServerPlaceholderFile() {
4367
+ function emitGeneratedServerPlaceholderFile(functionsDir) {
4368
+ const functionsDirHint = normalizeImportPath(path.relative(process.cwd(), functionsDir)) || "convex";
4306
4369
  return `// @ts-nocheck
4307
4370
  // biome-ignore-all format: generated
4308
4371
  /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
4309
4372
  // This file is auto-generated by kitcn
4310
4373
  // Do not edit manually. Run \`kitcn codegen\` to regenerate.
4311
4374
 
4375
+ import {
4376
+ registerProcedureNameLookup,
4377
+ } from 'kitcn/server';
4312
4378
  import type {
4313
4379
  ActionCtx as ServerActionCtx,
4314
4380
  MutationCtx as ServerMutationCtx,
@@ -4322,6 +4388,8 @@ export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
4322
4388
 
4323
4389
  ${CRPC_BUILDER_STUB_SOURCE}
4324
4390
 
4391
+ registerProcedureNameLookup({}, ${JSON.stringify(functionsDirHint)});
4392
+
4325
4393
  export function withOrm<Ctx>(ctx: Ctx): Ctx {
4326
4394
  return ctx;
4327
4395
  }
@@ -4368,7 +4436,7 @@ function ensureGeneratedSupportPlaceholders(functionsDir, options) {
4368
4436
  fs.mkdirSync(generatedDir, { recursive: true });
4369
4437
  const includeAuth = options?.includeAuth ?? true;
4370
4438
  if (!fs.existsSync(serverOutputFile)) {
4371
- writeFileIfChanged(serverOutputFile, emitGeneratedServerPlaceholderFile());
4439
+ writeFileIfChanged(serverOutputFile, emitGeneratedServerPlaceholderFile(functionsDir));
4372
4440
  createdPlaceholderFiles.push(serverOutputFile);
4373
4441
  }
4374
4442
  if (includeAuth && !fs.existsSync(authOutputFile)) {
@@ -4449,7 +4517,7 @@ function cleanupGeneratedPluginArtifacts(functionsDir) {
4449
4517
  force: true
4450
4518
  });
4451
4519
  }
4452
- function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasMigrationsManifest) {
4520
+ function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasMigrationsManifest, procedureNameLookup) {
4453
4521
  const asSingleQuotedImport = (importPath) => `'${importPath.replaceAll("'", "\\'")}'`;
4454
4522
  const serverTypesImportPath = getServerTypesImportPath(outputFile, functionsDir);
4455
4523
  const dataModelImportPath = getDataModelImportPath(outputFile, functionsDir);
@@ -4461,11 +4529,16 @@ function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasMigr
4461
4529
  const migrationsManifestImportLiteral = asSingleQuotedImport(migrationsManifestImportPath);
4462
4530
  const migrationsImportLine = hasMigrationsManifest ? `import { migrations } from ${migrationsManifestImportLiteral};\n` : "";
4463
4531
  const migrationsConfigLine = hasMigrationsManifest ? " migrations,\n" : "";
4532
+ const functionsDirHint = normalizeImportPath(path.relative(process.cwd(), functionsDir)) || "convex";
4533
+ const procedureNameLookupLiteral = emitProcedureNameLookupLiteral(procedureNameLookup);
4464
4534
  if (!hasOrmSchema) return `// biome-ignore-all format: generated
4465
4535
  // This file is auto-generated by kitcn
4466
4536
  // Do not edit manually. Run \`kitcn codegen\` to regenerate.
4467
4537
 
4468
- import { initCRPC as baseInitCRPC } from 'kitcn/server';
4538
+ import {
4539
+ initCRPC as baseInitCRPC,
4540
+ registerProcedureNameLookup,
4541
+ } from 'kitcn/server';
4469
4542
  import type { DataModel } from ${dataModelImportLiteral};
4470
4543
  import type {
4471
4544
  ActionCtx as ServerActionCtx,
@@ -4480,6 +4553,11 @@ export type ActionCtx = ServerActionCtx;
4480
4553
  export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
4481
4554
  export type OrmCtx<Ctx = QueryCtx> = Ctx;
4482
4555
 
4556
+ registerProcedureNameLookup(
4557
+ ${procedureNameLookupLiteral},
4558
+ ${JSON.stringify(functionsDirHint)}
4559
+ );
4560
+
4483
4561
  export function withOrm<Ctx extends ServerQueryCtx | ServerMutationCtx>(ctx: Ctx): OrmCtx<Ctx> {
4484
4562
  return ctx as OrmCtx<Ctx>;
4485
4563
  }
@@ -4504,6 +4582,7 @@ import {
4504
4582
  import {
4505
4583
  createGeneratedFunctionReference,
4506
4584
  initCRPC as baseInitCRPC,
4585
+ registerProcedureNameLookup,
4507
4586
  } from 'kitcn/server';
4508
4587
  import type { DataModel } from ${dataModelImportLiteral};
4509
4588
  import type {
@@ -4524,6 +4603,11 @@ ${`const ormFunctions: OrmFunctions = {
4524
4603
  };`}
4525
4604
  const ormSchema = schema;
4526
4605
 
4606
+ registerProcedureNameLookup(
4607
+ ${procedureNameLookupLiteral},
4608
+ ${JSON.stringify(functionsDirHint)}
4609
+ );
4610
+
4527
4611
  export const orm = createOrm({
4528
4612
  schema: ormSchema,
4529
4613
  ormFunctions,
@@ -5037,6 +5121,7 @@ async function generateMeta(sharedDir, options) {
5037
5121
  const meta = {};
5038
5122
  const allHttpRoutes = {};
5039
5123
  const procedureEntries = [];
5124
+ const procedureNameLookup = {};
5040
5125
  const fatalParseFailures = [];
5041
5126
  let createdRuntimePlaceholders = [];
5042
5127
  let createdSupportPlaceholders = [];
@@ -5065,6 +5150,7 @@ async function generateMeta(sharedDir, options) {
5065
5150
  try {
5066
5151
  const jitiInstance = createProjectJiti();
5067
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));
5068
5154
  const existingRuntimeFilesBeforeParse = new Set(listGeneratedRuntimeFiles(functionsDir));
5069
5155
  const runtimePlaceholderModules = [...new Set([
5070
5156
  ...files.map((file) => file.replace(TS_EXTENSION_RE$2, "")),
@@ -5072,7 +5158,7 @@ async function generateMeta(sharedDir, options) {
5072
5158
  ...generateAuth ? [generatedAuthModuleName] : []
5073
5159
  ])];
5074
5160
  createdRuntimePlaceholders = ensureGeneratedRuntimePlaceholders(functionsDir, runtimePlaceholderModules, resolveModuleRuntimeExportNames(runtimePlaceholderModules, normalizedTrimSegments));
5075
- for (const file of files) {
5161
+ for (const file of parseCandidateFiles) {
5076
5162
  const filePath = path.join(functionsDir, file);
5077
5163
  const moduleName = file.replace(TS_EXTENSION_RE$2, "");
5078
5164
  try {
@@ -5092,6 +5178,13 @@ async function generateMeta(sharedDir, options) {
5092
5178
  type: procedure.type,
5093
5179
  kind: "crpc"
5094
5180
  });
5181
+ const procedureNameEntries = buildProcedureNameLookupEntries({
5182
+ file,
5183
+ filePath,
5184
+ moduleName,
5185
+ procedures
5186
+ });
5187
+ if (procedureNameEntries.length > 0) procedureNameLookup[file] = procedureNameEntries;
5095
5188
  } catch (error) {
5096
5189
  const runtimeFile = getGeneratedRuntimeOutputFile(functionsDir, moduleName);
5097
5190
  if (existingRuntimeFilesBeforeParse.has(runtimeFile)) runtimeFilesPreservedFromParseFailures.add(runtimeFile);
@@ -5172,7 +5265,7 @@ ${optionalTypeExports}
5172
5265
  if (!fs.existsSync(outputDirname)) fs.mkdirSync(outputDirname, { recursive: true });
5173
5266
  writeFileIfChanged(outputFile, output);
5174
5267
  } else fs.rmSync(outputFile, { force: true });
5175
- const serverOutput = emitGeneratedServerFile(serverOutputFile, functionsDir, hasOrmSchema, hasMigrationsManifest);
5268
+ const serverOutput = emitGeneratedServerFile(serverOutputFile, functionsDir, hasOrmSchema, hasMigrationsManifest, procedureNameLookup);
5176
5269
  const generatedOutputDirname = path.dirname(serverOutputFile);
5177
5270
  if (!fs.existsSync(generatedOutputDirname)) fs.mkdirSync(generatedOutputDirname, { recursive: true });
5178
5271
  writeFileIfChanged(serverOutputFile, serverOutput);
@@ -925,9 +925,19 @@ function createNewHttpBuilder(def1, def2) {
925
925
  ...def2
926
926
  });
927
927
  }
928
+ function resolveHttpProcedureInfo(def) {
929
+ const route = def.route;
930
+ return {
931
+ type: "httpAction",
932
+ name: def.procedureName ?? (route ? `${route.method} ${route.path}` : void 0),
933
+ method: route?.method,
934
+ path: route?.path
935
+ };
936
+ }
928
937
  /** Internal method to create the HTTP procedure */
929
938
  function createProcedure(def, handler, _type) {
930
939
  if (!def.route) throw new Error("Route must be defined before action. Use .route(path, method) first.");
940
+ const middlewareProcedure = resolveHttpProcedureInfo(def);
931
941
  /**
932
942
  * Hono-compatible handler function.
933
943
  * When used with HttpRouterWithHono, Convex ctx is passed via c.env.
@@ -947,6 +957,7 @@ function createProcedure(def, handler, _type) {
947
957
  for (const middleware of def.middlewares) {
948
958
  const result = await middleware({
949
959
  ctx,
960
+ procedure: middlewareProcedure,
950
961
  input: currentInput,
951
962
  getRawInput,
952
963
  next: async (opts) => {
@@ -1092,6 +1103,9 @@ function createHttpBuilder(def) {
1092
1103
  ...value
1093
1104
  } : value });
1094
1105
  },
1106
+ name(value) {
1107
+ return createNewHttpBuilder(def, { procedureName: value });
1108
+ },
1095
1109
  route(path, method) {
1096
1110
  const pathParamNames = extractPathParams(path);
1097
1111
  return createNewHttpBuilder(def, { route: {
@@ -1363,6 +1377,117 @@ function extractRouteMap(procedures) {
1363
1377
  return result;
1364
1378
  }
1365
1379
 
1380
+ //#endregion
1381
+ //#region src/server/procedure-name.ts
1382
+ const LOOKUP_KEY = "__KITCN_PROCEDURE_NAME_LOOKUP__";
1383
+ const HINTS_KEY = "__KITCN_PROCEDURE_NAME_HINTS__";
1384
+ const PATH_SEPARATOR_RE = /\\/g;
1385
+ const TRIM_SLASHES_RE = /^\/+|\/+$/g;
1386
+ const PACKAGE_FRAME_MARKERS = ["/node_modules/kitcn/", "/packages/kitcn/"];
1387
+ function decodeFileName(value) {
1388
+ if (!value.startsWith("file://")) return value;
1389
+ try {
1390
+ return decodeURIComponent(new URL(value).pathname);
1391
+ } catch {
1392
+ return value;
1393
+ }
1394
+ }
1395
+ function normalizePath(value) {
1396
+ return value.replace(PATH_SEPARATOR_RE, "/");
1397
+ }
1398
+ function normalizeHint(value) {
1399
+ return normalizePath(value).replace(TRIM_SLASHES_RE, "");
1400
+ }
1401
+ function getGlobalLookup() {
1402
+ const globalScope = globalThis;
1403
+ const existing = globalScope[LOOKUP_KEY];
1404
+ if (existing && typeof existing === "object") return existing;
1405
+ const lookup = {};
1406
+ globalScope[LOOKUP_KEY] = lookup;
1407
+ return lookup;
1408
+ }
1409
+ function getGlobalHints() {
1410
+ const globalScope = globalThis;
1411
+ const existing = globalScope[HINTS_KEY];
1412
+ if (Array.isArray(existing)) return existing;
1413
+ const hints = [];
1414
+ globalScope[HINTS_KEY] = hints;
1415
+ return hints;
1416
+ }
1417
+ function registerProcedureNameLookup(lookup, functionsDirHint) {
1418
+ const globalLookup = getGlobalLookup();
1419
+ for (const [relativeFilePath, entries] of Object.entries(lookup)) {
1420
+ const key = normalizePath(relativeFilePath);
1421
+ const existing = globalLookup[key] ?? [];
1422
+ const deduped = /* @__PURE__ */ new Map();
1423
+ for (const entry of [...existing, ...entries]) deduped.set(`${entry.line}:${entry.column}:${entry.name}`, entry);
1424
+ globalLookup[key] = [...deduped.values()].sort((left, right) => left.line - right.line || left.column - right.column || left.name.localeCompare(right.name));
1425
+ }
1426
+ const normalizedHint = normalizeHint(functionsDirHint);
1427
+ if (!normalizedHint) return;
1428
+ const hints = getGlobalHints();
1429
+ if (!hints.includes(normalizedHint)) {
1430
+ hints.push(normalizedHint);
1431
+ hints.sort((left, right) => right.length - left.length);
1432
+ }
1433
+ }
1434
+ function isPackageFrame(filePath) {
1435
+ const normalized = normalizePath(filePath);
1436
+ return PACKAGE_FRAME_MARKERS.some((marker) => normalized.includes(marker));
1437
+ }
1438
+ function captureCallsite() {
1439
+ const originalPrepareStackTrace = Error.prepareStackTrace;
1440
+ try {
1441
+ Error.prepareStackTrace = (_error, stack) => stack;
1442
+ const frames = (/* @__PURE__ */ new Error("Capture procedure callsite for middleware name inference.")).stack;
1443
+ for (const frame of frames ?? []) {
1444
+ const rawFileName = frame.getFileName?.();
1445
+ if (!rawFileName) continue;
1446
+ const filePath = normalizePath(decodeFileName(rawFileName));
1447
+ if (filePath.startsWith("node:") || isPackageFrame(filePath)) continue;
1448
+ const line = frame.getLineNumber?.();
1449
+ const column = frame.getColumnNumber?.();
1450
+ if (!line || !column) continue;
1451
+ return {
1452
+ filePath,
1453
+ line,
1454
+ column
1455
+ };
1456
+ }
1457
+ } catch {
1458
+ return;
1459
+ } finally {
1460
+ Error.prepareStackTrace = originalPrepareStackTrace;
1461
+ }
1462
+ }
1463
+ function resolveRelativeFilePath(filePath) {
1464
+ const normalizedFilePath = normalizePath(filePath);
1465
+ const hints = getGlobalHints();
1466
+ for (const hint of hints) {
1467
+ const marker = `/${hint}/`;
1468
+ const markerIndex = normalizedFilePath.lastIndexOf(marker);
1469
+ if (markerIndex >= 0) return normalizedFilePath.slice(markerIndex + marker.length);
1470
+ if (normalizedFilePath.startsWith(`${hint}/`)) return normalizedFilePath.slice(hint.length + 1);
1471
+ }
1472
+ }
1473
+ function findBestEntry(entries, location) {
1474
+ const sameLine = entries.filter((entry) => entry.line === location.line);
1475
+ if (sameLine.length === 0) return;
1476
+ return sameLine.reduce((best, entry) => {
1477
+ const bestDistance = Math.abs(best.column - location.column);
1478
+ return Math.abs(entry.column - location.column) < bestDistance ? entry : best;
1479
+ });
1480
+ }
1481
+ function inferProcedureNameFromCallsite() {
1482
+ const location = captureCallsite();
1483
+ if (!location) return;
1484
+ const relativeFilePath = resolveRelativeFilePath(location.filePath);
1485
+ if (!relativeFilePath) return;
1486
+ const entries = getGlobalLookup()[relativeFilePath];
1487
+ if (!entries || entries.length === 0) return;
1488
+ return findBestEntry(entries, location)?.name;
1489
+ }
1490
+
1366
1491
  //#endregion
1367
1492
  //#region src/server/builder.ts
1368
1493
  /**
@@ -1408,8 +1533,15 @@ function createMiddlewareFactory() {
1408
1533
  return createMiddlewareInner([fn]);
1409
1534
  };
1410
1535
  }
1536
+ const FUNCTION_NAME_SYMBOL = Symbol.for("functionName");
1537
+ const resolveProcedureInfo = (type, procedureName, procedureFn) => {
1538
+ return {
1539
+ type,
1540
+ name: (procedureFn && typeof procedureFn === "object" && typeof procedureFn[FUNCTION_NAME_SYMBOL] === "string" ? procedureFn[FUNCTION_NAME_SYMBOL] : void 0) ?? procedureName
1541
+ };
1542
+ };
1411
1543
  /** Execute middleware chain recursively with input access */
1412
- async function executeMiddlewares(middlewares, ctx, meta, input, getRawInput, index = 0) {
1544
+ async function executeMiddlewares(middlewares, ctx, meta, procedure, input, getRawInput, index = 0) {
1413
1545
  if (index >= middlewares.length) return {
1414
1546
  marker: void 0,
1415
1547
  ctx,
@@ -1421,13 +1553,14 @@ async function executeMiddlewares(middlewares, ctx, meta, input, getRawInput, in
1421
1553
  const nextCtx = opts?.ctx ?? ctx;
1422
1554
  const nextInput = opts?.input ?? currentInput;
1423
1555
  if (opts?.input !== void 0) currentInput = opts.input;
1424
- return await executeMiddlewares(middlewares, nextCtx, meta, nextInput, getRawInput, index + 1);
1556
+ return await executeMiddlewares(middlewares, nextCtx, meta, procedure, nextInput, getRawInput, index + 1);
1425
1557
  };
1426
1558
  return {
1427
1559
  marker: void 0,
1428
1560
  ctx: (await middleware({
1429
1561
  ctx,
1430
1562
  meta,
1563
+ procedure,
1431
1564
  input,
1432
1565
  getRawInput,
1433
1566
  next
@@ -1630,6 +1763,13 @@ var ProcedureBuilder = class {
1630
1763
  } : value
1631
1764
  };
1632
1765
  }
1766
+ /** Set server-only procedure name for middleware/logging */
1767
+ _name(value) {
1768
+ return {
1769
+ ...this._def,
1770
+ procedureName: value
1771
+ };
1772
+ }
1633
1773
  /** Merge all input schemas into one */
1634
1774
  _getMergedInput() {
1635
1775
  const { inputSchemas } = this._def;
@@ -1637,7 +1777,7 @@ var ProcedureBuilder = class {
1637
1777
  return Object.assign({}, ...inputSchemas);
1638
1778
  }
1639
1779
  _createFunction(handler, baseFunction, customFn, fnType) {
1640
- const { middlewares, outputSchema, meta, functionConfig, isInternal } = this._def;
1780
+ const { middlewares, outputSchema, meta, procedureName, functionConfig, isInternal } = this._def;
1641
1781
  const mergedInput = this._getMergedInput();
1642
1782
  const inputSchema = mergedInput ? z.object(mergedInput) : void 0;
1643
1783
  const convexArgs = resolveConvexArgsShape(mergedInput);
@@ -1646,7 +1786,9 @@ var ProcedureBuilder = class {
1646
1786
  const typedReturnsSchema = returnsSchema;
1647
1787
  const typedArgs = convexArgs ?? {};
1648
1788
  const shouldValidateOutputWithZod = !!outputSchema && returnsSchema !== outputSchema;
1649
- const fn = customFunction({
1789
+ const resolvedProcedureName = procedureName ?? inferProcedureNameFromCallsite();
1790
+ let fn;
1791
+ fn = customFunction({
1650
1792
  args: typedArgs,
1651
1793
  ...typedReturnsSchema ? { returns: typedReturnsSchema } : {},
1652
1794
  handler: async (ctx, rawInput) => {
@@ -1654,7 +1796,7 @@ var ProcedureBuilder = class {
1654
1796
  const parsedInput = inputSchema ? inputSchema.parse(decodedInput) : decodedInput;
1655
1797
  const getRawInput = async () => parsedInput;
1656
1798
  try {
1657
- const result = await executeMiddlewares(middlewares, ctx, meta, parsedInput, getRawInput);
1799
+ const result = await executeMiddlewares(middlewares, ctx, meta, resolveProcedureInfo(fnType, resolvedProcedureName, fn), parsedInput, getRawInput);
1658
1800
  const handlerInput = result.input === parsedInput ? parsedInput : functionConfig.transformer.input.deserialize(result.input ?? parsedInput);
1659
1801
  const output = await handler({
1660
1802
  ctx: result.ctx,
@@ -1696,6 +1838,10 @@ var QueryProcedureBuilder = class QueryProcedureBuilder extends ProcedureBuilder
1696
1838
  meta(value) {
1697
1839
  return new QueryProcedureBuilder(this._meta(value));
1698
1840
  }
1841
+ /** Set a server-only procedure name for middleware/logging */
1842
+ name(value) {
1843
+ return new QueryProcedureBuilder(this._name(value));
1844
+ }
1699
1845
  /** Define input schema (chainable - schemas are merged) */
1700
1846
  input(schema) {
1701
1847
  return new QueryProcedureBuilder(this._input(schema));
@@ -1768,6 +1914,10 @@ var MutationProcedureBuilder = class MutationProcedureBuilder extends ProcedureB
1768
1914
  meta(value) {
1769
1915
  return new MutationProcedureBuilder(this._meta(value));
1770
1916
  }
1917
+ /** Set a server-only procedure name for middleware/logging */
1918
+ name(value) {
1919
+ return new MutationProcedureBuilder(this._name(value));
1920
+ }
1771
1921
  /** Define input schema (chainable - schemas are merged) */
1772
1922
  input(schema) {
1773
1923
  return new MutationProcedureBuilder(this._input(schema));
@@ -1807,6 +1957,10 @@ var ActionProcedureBuilder = class ActionProcedureBuilder extends ProcedureBuild
1807
1957
  meta(value) {
1808
1958
  return new ActionProcedureBuilder(this._meta(value));
1809
1959
  }
1960
+ /** Set a server-only procedure name for middleware/logging */
1961
+ name(value) {
1962
+ return new ActionProcedureBuilder(this._name(value));
1963
+ }
1810
1964
  /** Define input schema (chainable - schemas are merged) */
1811
1965
  input(schema) {
1812
1966
  return new ActionProcedureBuilder(this._input(schema));
@@ -1972,4 +2126,4 @@ const initCRPC = {
1972
2126
  };
1973
2127
 
1974
2128
  //#endregion
1975
- export { zodOutputToConvexFields as A, convexToZodFields as C, zCustomQuery as D, zCustomMutation as E, zodToConvexFields as M, zid as O, convexToZod as S, zCustomAction as T, CRPC_ERROR_CODE_TO_HTTP as _, createMiddlewareFactory as a, isCRPCError as b, createHttpRouter as c, createHttpProcedureBuilder as d, extractPathParams as f, CRPC_ERROR_CODES_BY_KEY as g, CRPCError as h, QueryProcedureBuilder as i, zodToConvex as j, zodOutputToConvex as k, createHttpRouterFactory as l, matchPathParams as m, MutationProcedureBuilder as n, initCRPC as o, handleHttpError as p, ProcedureBuilder as r, HttpRouterWithHono as s, ActionProcedureBuilder as t, extractRouteMap as u, getCRPCErrorFromUnknown as v, withSystemFields as w, toCRPCError as x, getHTTPStatusCodeFromError as y };
2129
+ export { zid as A, toCRPCError as C, zCustomAction as D, withSystemFields as E, zodOutputToConvexFields as M, zodToConvex as N, zCustomMutation as O, zodToConvexFields as P, isCRPCError as S, convexToZodFields as T, CRPCError as _, createMiddlewareFactory as a, getCRPCErrorFromUnknown as b, registerProcedureNameLookup as c, createHttpRouterFactory as d, extractRouteMap as f, matchPathParams as g, handleHttpError as h, QueryProcedureBuilder as i, zodOutputToConvex as j, zCustomQuery as k, HttpRouterWithHono as l, extractPathParams as m, MutationProcedureBuilder as n, initCRPC as o, createHttpProcedureBuilder as p, ProcedureBuilder as r, inferProcedureNameFromCallsite as s, ActionProcedureBuilder as t, createHttpRouter as u, CRPC_ERROR_CODES_BY_KEY as v, convexToZod as w, getHTTPStatusCodeFromError as x, CRPC_ERROR_CODE_TO_HTTP as y };
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as resolveAddTemplateDefaults, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, Et as highlighter, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as createSpinner, K as withLocalCodegenEnv, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as promptForScaffoldTemplateSelection, R as runBackendFunction, S as isEntryPoint, St as stripConvexCommandNoise, T as parseBackendRunJson, Tt as logger, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as filterScaffoldTemplatePathMap, Y as collectPluginScaffoldTemplates, Z as promptForPluginSelection, _ as formatInfoOutput, _t as applyPluginDependencyInstall, a as cleanup, at as getSupportedPluginKeys, b as hasRemoteConvexDeploymentEnv, bt as resolveAuthEnvState, c as createCommandEnv, ct as resolvePluginScaffoldRoots, d as extractBackfillCliOptions, dt as getPluginLockfilePath, et as resolvePluginPreset, f as extractConcaveRunTargetArgs, ft as getSchemaFilePath, g as formatDocsOutput, gt as applyPlanningDependencyInstall, h as extractResetCliOptions, ht as applyDependencyHintsInstall, i as buildInitializationPlan, it as getPluginCatalogEntry, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as assertSchemaFileExists, m as extractMigrationDownOptions, mt as resolveSchemaInstalledPlugins, n as applyPluginInstallPlanFiles, nt as resolveTemplateSelectionSource, o as createBackendAdapter, ot as isSupportedPluginKey, p as extractMigrationCliOptions, pt as readPluginLockfile, q as withWorkingDirectory, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplatesByIdOrThrow, s as createBackendCommandEnv, st as buildPluginInstallPlan, t as applyDependencyInstallPlan, tt as resolvePresetScaffoldTemplates, u as extractBackendRunTargetArgs, ut as collectInstalledPluginKeys, v as getAggregateBackfillDeploymentKey, vt as inspectPluginDependencyInstall, w as parseArgs, x as isConvexDevPreRunConflictFlag, xt as serializeEnvValue, y as getDevAggregateBackfillStatePath, yt as resolveProjectScaffoldContext, z as runConfiguredCodegen } from "./backend-core-CGjsBIOp.mjs";
2
+ import { $ as resolveAddTemplateDefaults, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, Et as highlighter, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as createSpinner, K as withLocalCodegenEnv, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as promptForScaffoldTemplateSelection, R as runBackendFunction, S as isEntryPoint, St as stripConvexCommandNoise, T as parseBackendRunJson, Tt as logger, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as filterScaffoldTemplatePathMap, Y as collectPluginScaffoldTemplates, Z as promptForPluginSelection, _ as formatInfoOutput, _t as applyPluginDependencyInstall, a as cleanup, at as getSupportedPluginKeys, b as hasRemoteConvexDeploymentEnv, bt as resolveAuthEnvState, c as createCommandEnv, ct as resolvePluginScaffoldRoots, d as extractBackfillCliOptions, dt as getPluginLockfilePath, et as resolvePluginPreset, f as extractConcaveRunTargetArgs, ft as getSchemaFilePath, g as formatDocsOutput, gt as applyPlanningDependencyInstall, h as extractResetCliOptions, ht as applyDependencyHintsInstall, i as buildInitializationPlan, it as getPluginCatalogEntry, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as assertSchemaFileExists, m as extractMigrationDownOptions, mt as resolveSchemaInstalledPlugins, n as applyPluginInstallPlanFiles, nt as resolveTemplateSelectionSource, o as createBackendAdapter, ot as isSupportedPluginKey, p as extractMigrationCliOptions, pt as readPluginLockfile, q as withWorkingDirectory, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplatesByIdOrThrow, s as createBackendCommandEnv, st as buildPluginInstallPlan, t as applyDependencyInstallPlan, tt as resolvePresetScaffoldTemplates, u as extractBackendRunTargetArgs, ut as collectInstalledPluginKeys, v as getAggregateBackfillDeploymentKey, vt as inspectPluginDependencyInstall, w as parseArgs, x as isConvexDevPreRunConflictFlag, xt as serializeEnvValue, y as getDevAggregateBackfillStatePath, yt as resolveProjectScaffoldContext, z as runConfiguredCodegen } from "./backend-core-C0uwGXLx.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";
@@ -5,13 +5,20 @@ type GenericCtx<DataModel extends GenericDataModel = GenericDataModel> = Generic
5
5
  type RunMutationCtx<DataModel extends GenericDataModel> = (GenericMutationCtx<DataModel> | GenericActionCtx<DataModel>) & {
6
6
  runMutation: GenericMutationCtx<DataModel>['runMutation'];
7
7
  };
8
+ type SchedulerCtx<TCtx> = TCtx extends {
9
+ scheduler?: infer TScheduler;
10
+ } ? TCtx & {
11
+ scheduler: NonNullable<TScheduler>;
12
+ } : never;
8
13
  declare const isQueryCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is GenericQueryCtx<DataModel>;
9
14
  declare const isMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is GenericMutationCtx<DataModel>;
10
15
  declare const isActionCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is GenericActionCtx<DataModel>;
11
16
  declare const isRunMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => ctx is RunMutationCtx<DataModel>;
17
+ declare const isSchedulerCtx: <TCtx extends object>(ctx: TCtx) => ctx is SchedulerCtx<TCtx>;
12
18
  declare const requireQueryCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => GenericQueryCtx<DataModel>;
13
19
  declare const requireMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => GenericMutationCtx<DataModel>;
14
20
  declare const requireActionCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => GenericActionCtx<DataModel>;
15
21
  declare const requireRunMutationCtx: <DataModel extends GenericDataModel>(ctx: GenericCtx<DataModel>) => RunMutationCtx<DataModel>;
22
+ declare const requireSchedulerCtx: <TCtx extends object>(ctx: TCtx) => SchedulerCtx<TCtx>;
16
23
  //#endregion
17
- export { isQueryCtx as a, requireMutationCtx as c, isMutationCtx as i, requireQueryCtx as l, RunMutationCtx as n, isRunMutationCtx as o, isActionCtx as r, requireActionCtx as s, GenericCtx as t, requireRunMutationCtx as u };
24
+ export { isMutationCtx as a, isSchedulerCtx as c, requireQueryCtx as d, requireRunMutationCtx as f, isActionCtx as i, requireActionCtx as l, RunMutationCtx as n, isQueryCtx as o, requireSchedulerCtx as p, SchedulerCtx as r, isRunMutationCtx as s, GenericCtx as t, requireMutationCtx as u };