kitcn 0.12.18 → 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.
Files changed (32) hide show
  1. package/dist/aggregate/index.d.ts +1 -1
  2. package/dist/{api-entry-BckXqaLb.js → api-entry-BMCQSsCw.js} +6 -1
  3. package/dist/auth/generated/index.d.ts +1 -1
  4. package/dist/auth/index.d.ts +13 -13
  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-UsFjh8jz.d.ts} +30 -30
  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-CuH2JNxb.d.ts} +30 -30
  30. package/package.json +1 -1
  31. package/skills/convex/SKILL.md +5 -4
  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-CuH2JNxb.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;
@@ -21,6 +22,10 @@ const requireRunMutationCtx = (ctx) => {
21
22
  if (!isRunMutationCtx(ctx)) throw new Error("Mutation or action context required");
22
23
  return ctx;
23
24
  };
25
+ const requireSchedulerCtx = (ctx) => {
26
+ if (!isSchedulerCtx(ctx)) throw new Error("Mutation or action context with scheduler required");
27
+ return ctx;
28
+ };
24
29
 
25
30
  //#endregion
26
31
  //#region src/server/api-entry.ts
@@ -63,4 +68,4 @@ function createGeneratedFunctionReference(name) {
63
68
  }
64
69
 
65
70
  //#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 };
71
+ 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-UsFjh8jz.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-UsFjh8jz.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";
@@ -103,25 +103,25 @@ type AdapterPaginationOptions = PaginationOptions & {
103
103
  maximumRowsRead?: number;
104
104
  };
105
105
  declare const adapterWhereValidator: convex_values0.VObject<{
106
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
106
107
  connector?: "AND" | "OR" | undefined;
107
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
108
108
  value: string | number | boolean | string[] | number[] | null;
109
109
  field: string;
110
110
  }, {
111
111
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
112
112
  field: convex_values0.VString<string, "required">;
113
- operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
113
+ operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
114
114
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
115
- }, "required", "value" | "connector" | "field" | "operator">;
115
+ }, "required", "operator" | "value" | "field" | "connector">;
116
116
  declare const adapterArgsValidator: convex_values0.VObject<{
117
- select?: string[] | undefined;
117
+ limit?: number | undefined;
118
118
  where?: {
119
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
119
120
  connector?: "AND" | "OR" | undefined;
120
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
121
121
  value: string | number | boolean | string[] | number[] | null;
122
122
  field: string;
123
123
  }[] | undefined;
124
- limit?: number | undefined;
124
+ select?: string[] | undefined;
125
125
  offset?: number | undefined;
126
126
  sortBy?: {
127
127
  field: string;
@@ -141,22 +141,22 @@ declare const adapterArgsValidator: convex_values0.VObject<{
141
141
  field: convex_values0.VString<string, "required">;
142
142
  }, "optional", "field" | "direction">;
143
143
  where: convex_values0.VArray<{
144
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
144
145
  connector?: "AND" | "OR" | undefined;
145
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
146
146
  value: string | number | boolean | string[] | number[] | null;
147
147
  field: string;
148
148
  }[] | undefined, convex_values0.VObject<{
149
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
149
150
  connector?: "AND" | "OR" | undefined;
150
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
151
151
  value: string | number | boolean | string[] | number[] | null;
152
152
  field: string;
153
153
  }, {
154
154
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
155
155
  field: convex_values0.VString<string, "required">;
156
- operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
156
+ operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
157
157
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
158
- }, "required", "value" | "connector" | "field" | "operator">, "optional">;
159
- }, "required", "model" | "select" | "where" | "limit" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
158
+ }, "required", "operator" | "value" | "field" | "connector">, "optional">;
159
+ }, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
160
160
  declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
161
161
  declare const checkUniqueFields: <Schema extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
162
162
  declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
@@ -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-BMCQSsCw.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);