kitcn 0.25.4 → 0.25.6

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.
@@ -1,5 +1,5 @@
1
1
  import { Bn as ConvexTextBuilderInitial, Xt as ConvexTableWithColumns } from "../capabilities-DtDfpdcH.js";
2
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-CCMtAIdx.js";
2
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-eTewPUGq.js";
3
3
  import * as convex_values0 from "convex/values";
4
4
  import { GenericId, Infer, Value } from "convex/values";
5
5
  import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
@@ -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-DwYwySy3.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-BEc4d98x.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-DJONf8X5.js";
2
2
  import { t as GetAuth } from "../types-Bf3XQex5.js";
3
3
  import { t as GenericCtx } from "../context-utils-DwZ3Cam1.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-DwYwySy3.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-BEc4d98x.js";
5
5
  import * as convex_values0 from "convex/values";
6
6
  import { Infer } from "convex/values";
7
7
  import { AuthConfig, DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
@@ -123,7 +123,6 @@ declare const adapterWhereValidator: convex_values0.VObject<{
123
123
  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>;
124
124
  }, "required", "mode" | "value" | "connector" | "field" | "operator">;
125
125
  declare const adapterArgsValidator: convex_values0.VObject<{
126
- limit?: number | undefined;
127
126
  select?: string[] | undefined;
128
127
  where?: {
129
128
  mode?: "sensitive" | "insensitive" | undefined;
@@ -132,10 +131,11 @@ declare const adapterArgsValidator: convex_values0.VObject<{
132
131
  value: string | number | boolean | string[] | number[] | null;
133
132
  field: string;
134
133
  }[] | undefined;
134
+ limit?: number | undefined;
135
135
  offset?: number | undefined;
136
136
  sortBy?: {
137
- direction: "asc" | "desc";
138
137
  field: string;
138
+ direction: "asc" | "desc";
139
139
  } | undefined;
140
140
  model: string;
141
141
  }, {
@@ -144,12 +144,12 @@ declare const adapterArgsValidator: convex_values0.VObject<{
144
144
  offset: convex_values0.VFloat64<number | undefined, "optional">;
145
145
  select: convex_values0.VArray<string[] | undefined, convex_values0.VString<string, "required">, "optional">;
146
146
  sortBy: convex_values0.VObject<{
147
- direction: "asc" | "desc";
148
147
  field: string;
148
+ direction: "asc" | "desc";
149
149
  } | undefined, {
150
150
  direction: convex_values0.VUnion<"asc" | "desc", [convex_values0.VLiteral<"asc", "required">, convex_values0.VLiteral<"desc", "required">], "required", never>;
151
151
  field: convex_values0.VString<string, "required">;
152
- }, "optional", "direction" | "field">;
152
+ }, "optional", "field" | "direction">;
153
153
  where: convex_values0.VArray<{
154
154
  mode?: "sensitive" | "insensitive" | undefined;
155
155
  connector?: "AND" | "OR" | undefined;
@@ -169,7 +169,7 @@ declare const adapterArgsValidator: convex_values0.VObject<{
169
169
  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>;
170
170
  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>;
171
171
  }, "required", "mode" | "value" | "connector" | "field" | "operator">, "optional">;
172
- }, "required", "limit" | "model" | "select" | "where" | "offset" | "sortBy" | "sortBy.direction" | "sortBy.field">;
172
+ }, "required", "model" | "select" | "where" | "limit" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
173
173
  declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
174
174
  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>;
175
175
  declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
@@ -934,6 +934,118 @@ const executeMiddlewares = async (middlewares, ctx, meta, procedure, input, getR
934
934
  };
935
935
  };
936
936
 
937
+ //#endregion
938
+ //#region src/server/validation.ts
939
+ const DYNAMIC_OUTPUT_PATH_SEGMENT = "<dynamic>";
940
+ /**
941
+ * Convert Zod issues into a Convex `Value` payload.
942
+ *
943
+ * `JSON.stringify` throws on a bigint, and an issue describing an `int64` bound
944
+ * carries one (`z.bigint().min(5n)` reports `minimum: 5n`). Stringifying those
945
+ * keeps the reported error about the schema mismatch instead of replacing it
946
+ * with a serialization failure.
947
+ */
948
+ function zodIssuesToConvexValue(issues) {
949
+ return JSON.parse(JSON.stringify(issues, (_key, value) => typeof value === "bigint" ? value.toString() : value));
950
+ }
951
+ /**
952
+ * Keep output-validation diagnostics useful without forwarding handler data.
953
+ *
954
+ * Zod's built-in issues omit the rejected value, but a schema-defined
955
+ * refinement can copy it into `message` or arbitrary custom fields. Output
956
+ * validation is a server fault, so client data is restricted to structural
957
+ * fields. The complete `ZodError` remains available as the error cause for
958
+ * server logs.
959
+ */
960
+ function expandOutputPathSchemas(schemas) {
961
+ const pending = schemas.map((schema) => schema);
962
+ const expanded = [];
963
+ const seen = /* @__PURE__ */ new Set();
964
+ while (pending.length > 0) {
965
+ const schema = pending.pop();
966
+ if (!schema || seen.has(schema)) continue;
967
+ seen.add(schema);
968
+ const definition = schema._zod.def;
969
+ if ([
970
+ "catch",
971
+ "default",
972
+ "nonoptional",
973
+ "nullable",
974
+ "optional",
975
+ "readonly"
976
+ ].includes(definition.type) && definition.innerType) pending.push(definition.innerType);
977
+ else if (definition.type === "lazy" && definition.getter) pending.push(definition.getter());
978
+ else if (definition.type === "pipe" && definition.in && definition.out) pending.push(definition.in, definition.out);
979
+ else if (definition.type === "union" && definition.options) pending.push(...definition.options);
980
+ else expanded.push(schema);
981
+ }
982
+ return expanded;
983
+ }
984
+ function sanitizeOutputIssuePath(schema, path) {
985
+ let candidates = expandOutputPathSchemas([schema]);
986
+ return path.map((segment) => {
987
+ const nextCandidates = [];
988
+ let isDeclaredObjectField = typeof segment === "string" && candidates.length > 0;
989
+ for (const candidate of candidates) {
990
+ const definition = candidate._zod.def;
991
+ const declaredField = definition.type === "object" && typeof segment === "string" && definition.shape?.[segment];
992
+ if (declaredField) {
993
+ nextCandidates.push(declaredField);
994
+ continue;
995
+ }
996
+ isDeclaredObjectField = false;
997
+ if (definition.type === "record" && definition.valueType) nextCandidates.push(definition.valueType);
998
+ else if (definition.type === "array" && definition.element) nextCandidates.push(definition.element);
999
+ else if (definition.type === "tuple" && typeof segment === "number") {
1000
+ const tupleChild = definition.items?.[segment] ?? definition.rest;
1001
+ if (tupleChild) nextCandidates.push(tupleChild);
1002
+ }
1003
+ }
1004
+ candidates = expandOutputPathSchemas(nextCandidates);
1005
+ return typeof segment === "string" && isDeclaredObjectField ? segment : DYNAMIC_OUTPUT_PATH_SEGMENT;
1006
+ });
1007
+ }
1008
+ function outputZodIssuesToConvexValue(schema, issues) {
1009
+ return issues.map((issue) => {
1010
+ const safeIssue = {
1011
+ code: issue.code,
1012
+ path: sanitizeOutputIssuePath(schema, issue.path)
1013
+ };
1014
+ if (issue.code === "invalid_type" && "expected" in issue && typeof issue.expected === "string") safeIssue.expected = issue.expected;
1015
+ return safeIssue;
1016
+ });
1017
+ }
1018
+ /**
1019
+ * Parse a handler's return value through its `.output()` schema.
1020
+ *
1021
+ * The value is parsed exactly as the handler produced it - `undefined` is not
1022
+ * normalized to `null` first, so a nullable schema needs an explicit `null`.
1023
+ *
1024
+ * A raw `ZodError` carries no `Symbol.for('ConvexError')`, so Convex strips its
1025
+ * message and `data` and hands the client an opaque `Server Error`, and the HTTP
1026
+ * router falls back to a generic 500. Wrapping it keeps the mismatch
1027
+ * self-diagnosing: Convex forwards `data` to the client, and `handleHttpError`
1028
+ * logs the whole error server-side rather than putting it in the response body.
1029
+ * The code is `INTERNAL_SERVER_ERROR` because a value the handler returned is a
1030
+ * server fault, not a client one, and it preserves the 500 the HTTP path already
1031
+ * returned. Client data retains only structural issue fields; custom messages
1032
+ * and fields can embed the rejected server value, so the complete Zod error is
1033
+ * kept in `cause` for server logs instead of forwarded.
1034
+ *
1035
+ * Only the parse is wrapped: a `ZodError` a handler threw itself keeps its
1036
+ * identity and travels through the caller's own error handling untouched.
1037
+ */
1038
+ async function parseOutput(schema, value) {
1039
+ const result = await schema.safeParseAsync(value);
1040
+ if (result.success) return result.data;
1041
+ throw new CRPCError({
1042
+ code: "INTERNAL_SERVER_ERROR",
1043
+ message: "Output validation failed",
1044
+ cause: result.error,
1045
+ data: { ZodError: outputZodIssuesToConvexValue(schema, result.error.issues) }
1046
+ });
1047
+ }
1048
+
937
1049
  //#endregion
938
1050
  //#region src/server/http-builder.ts
939
1051
  function extractPathParams(path) {
@@ -955,10 +1067,14 @@ function matchPathParams(template, pathname) {
955
1067
  }
956
1068
  function handleHttpError(error) {
957
1069
  const crpcError = toCRPCError(error);
958
- if (crpcError) return Response.json({ error: {
959
- code: crpcError.code,
960
- message: crpcError.message
961
- } }, { status: getHTTPStatusCodeFromError(crpcError) });
1070
+ if (crpcError) {
1071
+ const status = getHTTPStatusCodeFromError(crpcError);
1072
+ if (status >= 500) console.error("HTTP error:", crpcError);
1073
+ return Response.json({ error: {
1074
+ code: crpcError.code,
1075
+ message: crpcError.message
1076
+ } }, { status });
1077
+ }
962
1078
  console.error("Unhandled HTTP error:", error);
963
1079
  return Response.json({ error: {
964
1080
  code: "INTERNAL_SERVER_ERROR",
@@ -1150,7 +1266,7 @@ function createProcedure(def, handler, _type) {
1150
1266
  if (parsedForm !== void 0) handlerOpts.form = parsedForm;
1151
1267
  const result = await handler(handlerOpts);
1152
1268
  if (result instanceof Response) return result;
1153
- const output = def.outputSchema ? def.outputSchema.parse(result) : result;
1269
+ const output = def.outputSchema ? await parseOutput(def.outputSchema, result) : result;
1154
1270
  return c.json(def.functionConfig.transformer.output.serialize(output));
1155
1271
  })).output;
1156
1272
  } catch (error) {
@@ -1852,7 +1968,7 @@ const parseInput = (plan, value) => {
1852
1968
  }
1853
1969
  return parsed;
1854
1970
  } catch (cause) {
1855
- if (cause instanceof z$1.ZodError) throw new ConvexError({ ZodError: JSON.parse(JSON.stringify(cause.issues, null, 2)) });
1971
+ if (cause instanceof z$1.ZodError) throw new ConvexError({ ZodError: zodIssuesToConvexValue(cause.issues) });
1856
1972
  throw cause;
1857
1973
  }
1858
1974
  };
@@ -1957,7 +2073,7 @@ var ProcedureBuilder = class {
1957
2073
  input: resolvedInput === parsedInput ? parsedInput : functionConfig.transformer.input.deserialize(resolvedInput ?? parsedInput)
1958
2074
  });
1959
2075
  });
1960
- const validatedOutput = outputSchema ? await outputSchema.parseAsync(result.output) : result.output;
2076
+ const validatedOutput = outputSchema ? await parseOutput(outputSchema, result.output) : result.output;
1961
2077
  return functionConfig.transformer.output.serialize(validatedOutput);
1962
2078
  } catch (cause) {
1963
2079
  const err = toCRPCError(cause);
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-Dkh4a_BK.mjs";
2
+ import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-CiPqNKS_.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import fs, { existsSync, readFileSync } from "node:fs";
5
5
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
@@ -224,7 +224,6 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
224
224
  };
225
225
  }, Promise<Record<string, unknown> | undefined>>;
226
226
  findMany: convex_server0.RegisteredQuery<"internal", {
227
- limit?: number | undefined;
228
227
  join?: any;
229
228
  where?: {
230
229
  mode?: "sensitive" | "insensitive" | undefined;
@@ -233,10 +232,11 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
233
232
  value: string | number | boolean | string[] | number[] | null;
234
233
  field: string;
235
234
  }[] | undefined;
235
+ limit?: number | undefined;
236
236
  offset?: number | undefined;
237
237
  sortBy?: {
238
- direction: "asc" | "desc";
239
238
  field: string;
239
+ direction: "asc" | "desc";
240
240
  } | undefined;
241
241
  model: string;
242
242
  paginationOpts: {
@@ -473,8 +473,23 @@ export class CRPCError extends Error {
473
473
  }
474
474
  }
475
475
 
476
- export const createEnv = ({ schema }) => () =>
477
- typeof schema?.parse === "function" ? schema.parse(process.env) : process.env;
476
+ export const createEnv = ({ schema }) => () => {
477
+ if (typeof schema?.parse !== "function") return process.env;
478
+ if (globalThis.__KITCN_CODEGEN__ !== true || !schema.shape) {
479
+ return schema.parse(process.env);
480
+ }
481
+ const fallback = Object.fromEntries(
482
+ Object.entries(schema.shape).map(([key, zodType]) => {
483
+ const result = zodType?.safeParse?.(undefined);
484
+ if (result?.success) return [key, result.data];
485
+ if (Array.isArray(zodType?.options) && zodType.options.length > 0) {
486
+ return [key, zodType.options[0]];
487
+ }
488
+ return [key, ""];
489
+ })
490
+ );
491
+ return schema.parse({ ...fallback, ...process.env });
492
+ };
478
493
  export const createHttpRouter = (_app, httpRouter) => httpRouter ?? {};
479
494
  export const createCallerFactory = () => () => ({});
480
495
  export const createApiLeaf = (fnOrRoot, pathOrMeta, maybeMeta) => {
@@ -2587,6 +2602,9 @@ const TS_EXTENSION_RE = /\.ts$/;
2587
2602
  /** Pattern to detect default exports in auth contract files. */
2588
2603
  const DEFAULT_EXPORT_RE = /\bexport\s+default\b/;
2589
2604
  const MISSING_KITCN_IMPORT_RE = /Cannot find (?:module|package) ['"]kitcn(?:\/[^'"]+)?['"]/;
2605
+ const LEGACY_PROCEDURE_LOOKUP_START_RE = /\bregisterProcedureNameLookup\s*\(\s*(\{)/;
2606
+ const LEGACY_PROCEDURE_FILE_RE = /("(?:\\.|[^"\\])*")\s*:\s*\[([\s\S]*?)\]\s*,?/g;
2607
+ const LEGACY_PROCEDURE_ENTRY_RE = /\{\s*column:\s*(\d+)\s*,\s*line:\s*(\d+)\s*,\s*name:\s*("(?:\\.|[^"\\])*")\s*\}/g;
2590
2608
  const RUNTIME_CALLER_RESERVED_EXPORTS = new Set(["actions", "schedule"]);
2591
2609
  const DEFAULT_TRIM_SEGMENTS = ["plugins", "generated"];
2592
2610
  const CODEGEN_SCOPES$1 = new Set([
@@ -2784,6 +2802,59 @@ function emitProcedureNameLookupLiteral(lookup) {
2784
2802
  return ` ${JSON.stringify(file)}: [${items}],`;
2785
2803
  }).join("\n")}\n}`;
2786
2804
  }
2805
+ function extractObjectLiteral(source, startIndex) {
2806
+ let depth = 0;
2807
+ let quote = null;
2808
+ let escaped = false;
2809
+ for (let index = startIndex; index < source.length; index += 1) {
2810
+ const character = source[index];
2811
+ if (quote) {
2812
+ if (escaped) escaped = false;
2813
+ else if (character === "\\") escaped = true;
2814
+ else if (character === quote) quote = null;
2815
+ continue;
2816
+ }
2817
+ if (character === "\"" || character === "'") quote = character;
2818
+ else if (character === "{") depth += 1;
2819
+ else if (character === "}") {
2820
+ depth -= 1;
2821
+ if (depth === 0) return source.slice(startIndex, index + 1);
2822
+ }
2823
+ }
2824
+ return null;
2825
+ }
2826
+ function readLegacyProcedureNameLookup(serverOutputFile) {
2827
+ if (!fs.existsSync(serverOutputFile)) return;
2828
+ const source = fs.readFileSync(serverOutputFile, "utf8");
2829
+ const startMatch = LEGACY_PROCEDURE_LOOKUP_START_RE.exec(source);
2830
+ if (!startMatch || startMatch.index === void 0) return;
2831
+ const literal = extractObjectLiteral(source, startMatch.index + startMatch[0].lastIndexOf("{"));
2832
+ if (!literal) return;
2833
+ if (literal.trim() === "{}") return {};
2834
+ const lookup = {};
2835
+ for (const fileMatch of literal.matchAll(LEGACY_PROCEDURE_FILE_RE)) {
2836
+ const fileLiteral = fileMatch[1];
2837
+ const entriesLiteral = fileMatch[2];
2838
+ if (!fileLiteral || entriesLiteral === void 0) return;
2839
+ const file = JSON.parse(fileLiteral);
2840
+ if (typeof file !== "string") return;
2841
+ const entries = [];
2842
+ for (const entryMatch of entriesLiteral.matchAll(LEGACY_PROCEDURE_ENTRY_RE)) {
2843
+ const nameLiteral = entryMatch[3];
2844
+ if (!nameLiteral) return;
2845
+ const name = JSON.parse(nameLiteral);
2846
+ if (typeof name !== "string") return;
2847
+ entries.push({
2848
+ column: Number(entryMatch[1]),
2849
+ line: Number(entryMatch[2]),
2850
+ name
2851
+ });
2852
+ }
2853
+ if (entries.length === 0) return;
2854
+ lookup[file] = entries;
2855
+ }
2856
+ return Object.keys(lookup).length > 0 ? lookup : void 0;
2857
+ }
2787
2858
  function formatKey(key) {
2788
2859
  return VALID_IDENTIFIER_RE.test(key) ? key : `'${key}'`;
2789
2860
  }
@@ -2877,6 +2948,20 @@ function getModuleImportPath(outputFile, functionsDir, moduleName) {
2877
2948
  const moduleFile = path.join(functionsDir, moduleName);
2878
2949
  return ensureRelativeImportPath(normalizeImportPath(path.relative(path.dirname(outputFile), moduleFile)));
2879
2950
  }
2951
+ /**
2952
+ * Convex's own generated server module. `convex codegen` writes it, and kitcn
2953
+ * codegen runs before it on a first bootstrap, so it can legitimately be
2954
+ * missing.
2955
+ */
2956
+ function getConvexGeneratedServerFile(functionsDir) {
2957
+ const base = path.join(functionsDir, "_generated", "server");
2958
+ return [
2959
+ ".js",
2960
+ ".ts",
2961
+ ".mjs",
2962
+ ".cjs"
2963
+ ].map((extension) => `${base}${extension}`).find((candidate) => fs.existsSync(candidate));
2964
+ }
2880
2965
  function getRuntimeApiImportPath(outputFile, functionsDir) {
2881
2966
  const runtimeApiFile = path.join(functionsDir, "_generated", "api.js");
2882
2967
  return ensureRelativeImportPath(normalizeImportPath(path.relative(path.dirname(outputFile), runtimeApiFile)));
@@ -2931,6 +3016,17 @@ function getGeneratedAuthOutputFile(functionsDir) {
2931
3016
  function getGeneratedMigrationsHelperOutputFile(functionsDir) {
2932
3017
  return path.join(functionsDir, GENERATED_DIR, "migrations.gen.ts");
2933
3018
  }
3019
+ /**
3020
+ * The only parse-derived input to `generated/server.ts`, split into its own
3021
+ * module so `server.ts` stays fully determined by pre-parse facts and can be
3022
+ * written before codegen evaluates the modules that import it.
3023
+ *
3024
+ * Two dots in the basename keep Convex's entry-point walker from deploying it
3025
+ * as a function module, matching `migrations.gen.ts`.
3026
+ */
3027
+ function getGeneratedProcedureNamesOutputFile(functionsDir) {
3028
+ return path.join(functionsDir, GENERATED_DIR, "procedure-names.gen.ts");
3029
+ }
2934
3030
  function getLegacyGeneratedOutputFile(functionsDir) {
2935
3031
  return path.join(functionsDir, "generated.ts");
2936
3032
  }
@@ -2992,6 +3088,19 @@ export const getAuth = () => ({} as Record<string, unknown>);
2992
3088
  export const auth = {} as Record<string, unknown>;
2993
3089
  `;
2994
3090
  }
3091
+ /**
3092
+ * Pure data, zero imports: nothing here can throw while codegen evaluates the
3093
+ * project, and the value export survives tree-shaking even when the app sets
3094
+ * `"sideEffects": false` (a bare side-effect import would not).
3095
+ */
3096
+ function emitGeneratedProcedureNamesFile(procedureNameLookup) {
3097
+ return `// biome-ignore-all format: generated
3098
+ // This file is auto-generated by kitcn
3099
+ // Do not edit manually. Run \`kitcn codegen\` to regenerate.
3100
+
3101
+ export const procedureNames = ${emitProcedureNameLookupLiteral(procedureNameLookup)};
3102
+ `;
3103
+ }
2995
3104
  function emitGeneratedMigrationsPlaceholderFile() {
2996
3105
  return `// biome-ignore-all format: generated
2997
3106
  /* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-unused-vars */
@@ -3010,16 +3119,25 @@ function writeFileIfChanged(filePath, content) {
3010
3119
  }
3011
3120
  function ensureGeneratedSupportPlaceholders(functionsDir, options) {
3012
3121
  const createdPlaceholderFiles = [];
3122
+ const replacedFiles = [];
3013
3123
  const serverOutputFile = getGeneratedServerOutputFile(functionsDir);
3014
3124
  const authOutputFile = getGeneratedAuthOutputFile(functionsDir);
3015
3125
  const migrationsHelperOutputFile = getGeneratedMigrationsHelperOutputFile(functionsDir);
3126
+ const procedureNamesOutputFile = getGeneratedProcedureNamesOutputFile(functionsDir);
3016
3127
  const generatedDir = path.dirname(serverOutputFile);
3017
3128
  fs.mkdirSync(generatedDir, { recursive: true });
3018
3129
  const includeAuth = options?.includeAuth ?? true;
3019
3130
  if (!fs.existsSync(serverOutputFile)) {
3020
3131
  writeFileIfChanged(serverOutputFile, emitGeneratedServerPlaceholderFile(functionsDir));
3021
3132
  createdPlaceholderFiles.push(serverOutputFile);
3133
+ } else if (options?.replaceServer) {
3134
+ const content = fs.readFileSync(serverOutputFile, "utf8");
3135
+ if (writeFileIfChanged(serverOutputFile, emitGeneratedServerPlaceholderFile(functionsDir))) replacedFiles.push({
3136
+ content,
3137
+ filePath: serverOutputFile
3138
+ });
3022
3139
  }
3140
+ if (!fs.existsSync(procedureNamesOutputFile)) writeFileIfChanged(procedureNamesOutputFile, emitGeneratedProcedureNamesFile(options?.procedureNameLookup ?? {}));
3023
3141
  if (includeAuth && !fs.existsSync(authOutputFile)) {
3024
3142
  writeFileIfChanged(authOutputFile, emitGeneratedAuthPlaceholderFile());
3025
3143
  createdPlaceholderFiles.push(authOutputFile);
@@ -3028,7 +3146,22 @@ function ensureGeneratedSupportPlaceholders(functionsDir, options) {
3028
3146
  writeFileIfChanged(migrationsHelperOutputFile, emitGeneratedMigrationsPlaceholderFile());
3029
3147
  createdPlaceholderFiles.push(migrationsHelperOutputFile);
3030
3148
  }
3031
- return createdPlaceholderFiles;
3149
+ return {
3150
+ createdFiles: createdPlaceholderFiles,
3151
+ replacedFiles
3152
+ };
3153
+ }
3154
+ async function withCodegenParseSentinel(callback) {
3155
+ const globals = globalThis;
3156
+ const hadSentinel = Object.hasOwn(globals, "__KITCN_CODEGEN__");
3157
+ const previousSentinel = globals.__KITCN_CODEGEN__;
3158
+ globals.__KITCN_CODEGEN__ = true;
3159
+ try {
3160
+ return await callback();
3161
+ } finally {
3162
+ if (hadSentinel) globals.__KITCN_CODEGEN__ = previousSentinel;
3163
+ else delete globals.__KITCN_CODEGEN__;
3164
+ }
3032
3165
  }
3033
3166
  function emitGeneratedRuntimePlaceholderFile(exportNames) {
3034
3167
  const { callerExportName, handlerExportName } = exportNames;
@@ -3086,8 +3219,7 @@ async function resolveSchemaMetadataForCodegen(functionsDir, debug, createJitiIn
3086
3219
  hasTriggers
3087
3220
  };
3088
3221
  } catch (error) {
3089
- if (debug) logger.warn(`⚠️ Failed to load schema extensions from ${schemaPath}: ${error.message}`);
3090
- return EMPTY_SCHEMA_METADATA;
3222
+ throw new Error(`kitcn codegen could not load ${schemaPath}: ${error.message}`, { cause: error });
3091
3223
  }
3092
3224
  }
3093
3225
  /**
@@ -3108,7 +3240,13 @@ function cleanupGeneratedPluginArtifacts(functionsDir) {
3108
3240
  force: true
3109
3241
  });
3110
3242
  }
3111
- function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasAggregateIndexes, hasMigrationsManifest, procedureNameLookup) {
3243
+ /**
3244
+ * Every input here is known before codegen evaluates any project module, so
3245
+ * this file is written first and is authoritative: a stale copy on disk is
3246
+ * replaced before anything can import it. The parse-derived procedure-name
3247
+ * lookup lives in `procedure-names.gen.ts` to keep that true.
3248
+ */
3249
+ function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasAggregateIndexes, hasMigrationsManifest) {
3112
3250
  const asSingleQuotedImport = (importPath) => `'${importPath.replaceAll("'", "\\'")}'`;
3113
3251
  const serverTypesImportPath = getServerTypesImportPath(outputFile, functionsDir);
3114
3252
  const dataModelImportPath = getDataModelImportPath(outputFile, functionsDir);
@@ -3124,7 +3262,7 @@ function emitGeneratedServerFile(outputFile, functionsDir, hasOrmSchema, hasAggr
3124
3262
  const capabilityEntries = [...hasAggregateIndexes ? ["aggregateCapability()"] : [], ...hasMigrationsManifest ? ["migrationCapability()"] : []];
3125
3263
  const capabilitiesConfigLine = capabilityEntries.length > 0 ? ` capabilities: [${capabilityEntries.join(", ")}],\n` : "";
3126
3264
  const functionsDirHint = normalizeImportPath(path.relative(process.cwd(), functionsDir)) || "convex";
3127
- const procedureNameLookupLiteral = emitProcedureNameLookupLiteral(procedureNameLookup);
3265
+ const procedureNamesImportLiteral = asSingleQuotedImport(ensureRelativeImportPath(normalizeImportPath(path.relative(path.dirname(outputFile), getGeneratedProcedureNamesOutputFile(functionsDir))).replace(TS_EXTENSION_RE, "")));
3128
3266
  if (!hasOrmSchema) return `// biome-ignore-all format: generated
3129
3267
  // This file is auto-generated by kitcn
3130
3268
  // Do not edit manually. Run \`kitcn codegen\` to regenerate.
@@ -3140,6 +3278,7 @@ import type {
3140
3278
  QueryCtx as ServerQueryCtx,
3141
3279
  } from ${serverTypesImportLiteral};
3142
3280
  import { httpAction, internalMutation } from ${serverTypesImportLiteral};
3281
+ import { procedureNames } from ${procedureNamesImportLiteral};
3143
3282
 
3144
3283
  export type QueryCtx = ServerQueryCtx;
3145
3284
  export type MutationCtx = ServerMutationCtx;
@@ -3147,10 +3286,7 @@ export type ActionCtx = ServerActionCtx;
3147
3286
  export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
3148
3287
  export type OrmCtx<Ctx = QueryCtx> = Ctx;
3149
3288
 
3150
- registerProcedureNameLookup(
3151
- ${procedureNameLookupLiteral},
3152
- ${JSON.stringify(functionsDirHint)}
3153
- );
3289
+ registerProcedureNameLookup(procedureNames, ${JSON.stringify(functionsDirHint)});
3154
3290
 
3155
3291
  export function withOrm<Ctx extends ServerQueryCtx | ServerMutationCtx>(ctx: Ctx): OrmCtx<Ctx> {
3156
3292
  return ctx as OrmCtx<Ctx>;
@@ -3187,6 +3323,7 @@ import type {
3187
3323
  } from ${serverTypesImportLiteral};
3188
3324
  import { httpAction, internalMutation } from ${serverTypesImportLiteral};
3189
3325
  import schema from ${schemaImportLiteral};
3326
+ import { procedureNames } from ${procedureNamesImportLiteral};
3190
3327
  ${migrationsImportLine}
3191
3328
 
3192
3329
  ${`const ormFunctions: OrmFunctions = {
@@ -3198,10 +3335,7 @@ ${`const ormFunctions: OrmFunctions = {
3198
3335
  };`}
3199
3336
  const ormSchema = schema;
3200
3337
 
3201
- registerProcedureNameLookup(
3202
- ${procedureNameLookupLiteral},
3203
- ${JSON.stringify(functionsDirHint)}
3204
- );
3338
+ registerProcedureNameLookup(procedureNames, ${JSON.stringify(functionsDirHint)});
3205
3339
 
3206
3340
  export const orm = createOrm({
3207
3341
  schema: ormSchema,
@@ -3745,6 +3879,7 @@ async function generateMeta(sharedDir, options) {
3745
3879
  const crpcOutputFile = getGeneratedCrpcOutputFile(functionsDir);
3746
3880
  const authOutputFile = getGeneratedAuthOutputFile(functionsDir);
3747
3881
  const migrationsHelperOutputFile = getGeneratedMigrationsHelperOutputFile(functionsDir);
3882
+ const procedureNamesOutputFile = getGeneratedProcedureNamesOutputFile(functionsDir);
3748
3883
  const legacyGeneratedMigrationsOutputFile = path.join(functionsDir, GENERATED_DIR, "migrations.ts");
3749
3884
  const legacyGeneratedMigrationsRuntimeOutputFile = path.join(functionsDir, GENERATED_DIR, "migrations.runtime.ts");
3750
3885
  const legacyGeneratedMigrationsUnderscoreOutputFile = path.join(functionsDir, GENERATED_DIR, "_migrations.ts");
@@ -3761,7 +3896,10 @@ async function generateMeta(sharedDir, options) {
3761
3896
  const procedureNameLookup = {};
3762
3897
  const fatalParseFailures = [];
3763
3898
  let createdRuntimePlaceholders = [];
3764
- let createdSupportPlaceholders = [];
3899
+ let supportPlaceholderState = {
3900
+ createdFiles: [],
3901
+ replacedFiles: []
3902
+ };
3765
3903
  const runtimeFilesPreservedFromParseFailures = /* @__PURE__ */ new Set();
3766
3904
  let totalFunctions = 0;
3767
3905
  const authFilePath = path.join(functionsDir, "auth.ts");
@@ -3773,7 +3911,7 @@ async function generateMeta(sharedDir, options) {
3773
3911
  };
3774
3912
  let sharedJitiInstance;
3775
3913
  const getSharedJitiInstance = () => sharedJitiInstance ??= createProjectJiti();
3776
- const schemaMetadata = await resolveSchemaMetadataForCodegen(functionsDir, debug, getSharedJitiInstance);
3914
+ const schemaMetadata = await withCodegenParseSentinel(() => resolveSchemaMetadataForCodegen(functionsDir, debug, getSharedJitiInstance));
3777
3915
  const hasOrmSchemaMetadata = schemaMetadata.hasOrmSchema;
3778
3916
  const hasRelationsMetadata = schemaMetadata.hasRelations;
3779
3917
  const hasRelationsExport = hasNamedExport(path.join(functionsDir, "schema.ts"), "relations");
@@ -3783,7 +3921,14 @@ async function generateMeta(sharedDir, options) {
3783
3921
  if (hasRelationsExport) throw new Error("Codegen error: do not export `relations` from schema.ts. Chain relations on the default schema export with `defineSchema(...).relations(...)`.");
3784
3922
  if (hasSchemaTriggersExport || hasDedicatedTriggersExport) throw new Error("Codegen error: do not export `triggers` from schema.ts or triggers.ts. Chain triggers on the default schema export with `defineSchema(...).relations(...).triggers(...)`.");
3785
3923
  const hasOrmSchema = hasOrmSchemaMetadata;
3786
- createdSupportPlaceholders = ensureGeneratedSupportPlaceholders(functionsDir, { includeAuth: generateAuth });
3924
+ const convexGeneratedServerFile = getConvexGeneratedServerFile(functionsDir);
3925
+ supportPlaceholderState = ensureGeneratedSupportPlaceholders(functionsDir, {
3926
+ includeAuth: generateAuth,
3927
+ procedureNameLookup: fs.existsSync(procedureNamesOutputFile) ? void 0 : readLegacyProcedureNameLookup(serverOutputFile),
3928
+ replaceServer: convexGeneratedServerFile === void 0
3929
+ });
3930
+ const emitServerFile = () => writeFileIfChanged(serverOutputFile, emitGeneratedServerFile(serverOutputFile, functionsDir, hasOrmSchema, schemaMetadata.hasAggregateIndexes, hasMigrationsManifest));
3931
+ if (convexGeneratedServerFile) emitServerFile();
3787
3932
  if (generateApi) {
3788
3933
  globalThis.__KITCN_CODEGEN__ = true;
3789
3934
  try {
@@ -3844,7 +3989,8 @@ async function generateMeta(sharedDir, options) {
3844
3989
  }
3845
3990
  if (fatalParseFailures.length > 0) {
3846
3991
  for (const createdRuntimePlaceholder of createdRuntimePlaceholders) fs.rmSync(createdRuntimePlaceholder, { force: true });
3847
- for (const createdSupportPlaceholder of createdSupportPlaceholders) fs.rmSync(createdSupportPlaceholder, { force: true });
3992
+ for (const createdSupportPlaceholder of supportPlaceholderState.createdFiles) fs.rmSync(createdSupportPlaceholder, { force: true });
3993
+ for (const replacedSupportFile of supportPlaceholderState.replacedFiles) fs.writeFileSync(replacedSupportFile.filePath, replacedSupportFile.content, "utf8");
3848
3994
  const failureSummary = fatalParseFailures.map(({ file, error }) => `- ${file}: ${error instanceof Error ? error.message : String(error)}`).join("\n");
3849
3995
  throw new Error(`kitcn codegen aborted because module parsing failed:\n${failureSummary}`);
3850
3996
  }
@@ -3906,10 +4052,10 @@ ${optionalTypeExports}
3906
4052
  if (!fs.existsSync(outputDirname)) fs.mkdirSync(outputDirname, { recursive: true });
3907
4053
  writeFileIfChanged(outputFile, output);
3908
4054
  } else fs.rmSync(outputFile, { force: true });
3909
- const serverOutput = emitGeneratedServerFile(serverOutputFile, functionsDir, hasOrmSchema, schemaMetadata.hasAggregateIndexes, hasMigrationsManifest, procedureNameLookup);
3910
4055
  const generatedOutputDirname = path.dirname(serverOutputFile);
3911
4056
  if (!fs.existsSync(generatedOutputDirname)) fs.mkdirSync(generatedOutputDirname, { recursive: true });
3912
- writeFileIfChanged(serverOutputFile, serverOutput);
4057
+ emitServerFile();
4058
+ if (generateApi) writeFileIfChanged(procedureNamesOutputFile, emitGeneratedProcedureNamesFile(procedureNameLookup));
3913
4059
  if (hasOrmSchema) writeFileIfChanged(aggregateOutputFile, emitGeneratedAggregateFile(aggregateOutputFile, functionsDir));
3914
4060
  else fs.rmSync(aggregateOutputFile, { force: true });
3915
4061
  fs.rmSync(ormOutputFile, { force: true });
@@ -1,4 +1,4 @@
1
- import { a as createMiddlewareFactory } from "./builder-DoeyW4Vq.js";
1
+ import { a as createMiddlewareFactory } from "./builder-CsAw-DK8.js";
2
2
 
3
3
  //#region src/plugins/middleware.ts
4
4
  const PLUGIN_CONFIG_RESOLVERS = Symbol.for("kitcn:PluginConfigResolvers");
@@ -1,5 +1,5 @@
1
1
  import { $n as BinaryExpression, $t as OrmLifecycleOperation, A as DatabaseWithMutations, An as ConvexCheckConfig, Ar as AnyColumn, At as VectorQueryConfig, B as RlsContext, Bn as ConvexTextBuilderInitial, Br as IsUnique, Bt as RelationsBuilderColumnConfig, C as MigrationTableName, Cn as aggregateIndex, Cr as notBetween, Ct as OrderDirection, D as defineMigrationSet, Dn as uniqueIndex, Dt as ReturningResult, E as defineMigration, En as searchIndex, Er as startsWith, Et as ReturningAll, Fn as ConvexUniqueConstraintConfig, Fr as ColumnBuilderWithTableName, Ft as ExtractTablesWithRelations, Gt as defineRelations, H as EdgeMetadata, In as check, Ir as ColumnDataType, It as ManyConfig, Jt as ConvexDeletionConfig, Kt as defineRelationsPart, Ln as foreignKey, Lr as DrizzleEntity, Lt as OneConfig, M as OrmReader$1, Mn as ConvexForeignKeyConfig, Mr as ColumnBuilderBaseConfig, Mt as unsetToken, N as OrmWriter$1, Nn as ConvexUniqueConstraintBuilder, Nr as ColumnBuilderRuntimeConfig, O as detectMigrationDrift, On as vectorIndex, Or as SystemFields, Ot as ReturningSelection, Pn as ConvexUniqueConstraintBuilderOn, Pr as ColumnBuilderTypeConfig, Pt as ExtractTablesFromSchema, Qn as TableName, Qt as OrmLifecycleChange, Rn as unique, Rr as HasDefault, Rt as RelationsBuilder, S as MigrationStep, Sn as ConvexVectorIndexConfig, Sr as not, St as OrderByClause, T as buildMigrationPlan, Tn as rankIndex, Tr as or, Tt as PredicateWhereIndexConfig, U as extractRelationsConfig, Un as Brand, Ut as TableRelationalConfig, V as RlsMode, Vn as text, Vr as NotNull, Wn as Columns, Wt as TablesRelationalConfig, Xn as OrmSchemaRelations, Xt as ConvexTableWithColumns, Yn as OrmSchemaExtensions, Yt as ConvexTable, Zn as OrmSchemaTriggers, Zt as DiscriminatorBuilderConfig, _ as MigrationMigrateOne, _n as ConvexSearchIndexBuilder, _r as isNull, _t as MutationPaginateConfig, an as RlsPolicyConfig, ar as and, at as CountConfig, b as MigrationSet, bn as ConvexVectorIndexBuilder, br as lte, bt as MutationReturning, cn as RlsRole, cr as endsWith, ct as FilterOperators, d as MigrationDefinition, dn as ConvexAggregateIndexBuilder, dr as gt, dt as InferModelFromColumns, en as TableConfig, er as ExpressionVisitor, et as AggregateConfig, f as MigrationDirection, fn as ConvexAggregateIndexBuilderOn, fr as gte, ft as InferSelectModel, g as MigrationManifestEntry, gn as ConvexRankIndexBuilderOn, gr as isNotNull, gt as MutationExecutionMode, h as MigrationDriftIssue, hn as ConvexRankIndexBuilder, hr as isFieldReference, ht as MutationExecuteResult, i as OrmMigrationCapability, in as RlsPolicy, ir as UnaryExpression, it as BuildRelationResult, j as DatabaseWithQuery, jn as ConvexForeignKeyBuilder, jr as ColumnBuilder, jt as VectorSearchProvider, kn as ConvexCheckBuilder, kt as UpdateSet, ln as RlsRoleConfig, lr as eq, lt as GetColumnData, m as MigrationDocContext, mn as ConvexIndexBuilderOn, mr as inArray, mt as MutationExecuteConfig, n as OrmCapabilities, nn as deletion, nr as FilterExpression, nt as AggregateResult, on as RlsPolicyToOption, or as between, ot as CountResult, p as MigrationDoc, pn as ConvexIndexBuilder, pr as ilike, pt as InsertValue, qn as OrmSchemaExtensionTables, qt as ConvexDeletionBuilder, r as OrmCapability, rn as discriminator, rr as LogicalExpression, rt as BuildQueryResult, sn as rlsPolicy, sr as contains, st as DBQueryConfig, t as OrmAggregateCapability, tn as convexTable, tr as FieldReference, tt as AggregateFieldValue, u as MigrationAppliedState, un as rlsRole, ur as fieldRef, ut as InferInsertModel, v as MigrationPlan, vn as ConvexSearchIndexBuilderOn, vr as like, vt as MutationPaginatedResult, w as MigrationWriteMode, wn as index, wr as notInArray, wt as PaginatedResult, x as MigrationStateMap, xn as ConvexVectorIndexBuilderOn, xr as ne, xt as MutationRunMode, y as MigrationRunStatus, yn as ConvexSearchIndexConfig, yr as lt, yt as MutationResult, zn as ConvexTextBuilder, zr as IsPrimaryKey, zt as RelationsBuilderColumnBase } from "../capabilities-DtDfpdcH.js";
2
- import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-CCMtAIdx.js";
2
+ import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-eTewPUGq.js";
3
3
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-wOIjhkfN.js";
4
4
  import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-DJONf8X5.js";
5
5
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";