kitcn 0.15.5 → 0.15.7

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,4 +1,4 @@
1
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-DcEhkJ12.js";
1
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-Dc58we_m.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";
@@ -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-0xEF3NtW.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-3mwCSv2F.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-CNo9ffvI.js";
2
2
  import { t as GetAuth } from "../types-BCl8gfGy.js";
3
3
  import { t as GenericCtx } from "../context-utils-OMkMGhBk.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-0xEF3NtW.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-3mwCSv2F.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";
@@ -107,27 +107,27 @@ type AdapterPaginationOptions = PaginationOptions & {
107
107
  };
108
108
  declare const adapterWhereValidator: convex_values0.VObject<{
109
109
  mode?: "sensitive" | "insensitive" | undefined;
110
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
110
111
  connector?: "AND" | "OR" | undefined;
111
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
112
112
  value: string | number | boolean | string[] | number[] | null;
113
113
  field: string;
114
114
  }, {
115
115
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
116
116
  field: convex_values0.VString<string, "required">;
117
117
  mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
118
- 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>;
118
+ 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>;
119
119
  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>;
120
- }, "required", "mode" | "value" | "connector" | "field" | "operator">;
120
+ }, "required", "mode" | "operator" | "value" | "field" | "connector">;
121
121
  declare const adapterArgsValidator: convex_values0.VObject<{
122
- select?: string[] | undefined;
122
+ limit?: number | undefined;
123
123
  where?: {
124
124
  mode?: "sensitive" | "insensitive" | undefined;
125
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
125
126
  connector?: "AND" | "OR" | undefined;
126
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
127
127
  value: string | number | boolean | string[] | number[] | null;
128
128
  field: string;
129
129
  }[] | undefined;
130
- limit?: number | undefined;
130
+ select?: string[] | undefined;
131
131
  offset?: number | undefined;
132
132
  sortBy?: {
133
133
  field: string;
@@ -148,24 +148,24 @@ declare const adapterArgsValidator: convex_values0.VObject<{
148
148
  }, "optional", "field" | "direction">;
149
149
  where: convex_values0.VArray<{
150
150
  mode?: "sensitive" | "insensitive" | undefined;
151
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
151
152
  connector?: "AND" | "OR" | undefined;
152
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
153
153
  value: string | number | boolean | string[] | number[] | null;
154
154
  field: string;
155
155
  }[] | undefined, convex_values0.VObject<{
156
156
  mode?: "sensitive" | "insensitive" | undefined;
157
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
157
158
  connector?: "AND" | "OR" | undefined;
158
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
159
159
  value: string | number | boolean | string[] | number[] | null;
160
160
  field: string;
161
161
  }, {
162
162
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
163
163
  field: convex_values0.VString<string, "required">;
164
164
  mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
165
- 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>;
165
+ 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>;
166
166
  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>;
167
- }, "required", "mode" | "value" | "connector" | "field" | "operator">, "optional">;
168
- }, "required", "model" | "select" | "where" | "limit" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
167
+ }, "required", "mode" | "operator" | "value" | "field" | "connector">, "optional">;
168
+ }, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
169
169
  declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
170
170
  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>;
171
171
  declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
@@ -44,6 +44,7 @@ declare function convexBetterAuth<TApi extends Record<string, unknown>>(opts: Co
44
44
  }) => Promise<ConvexContext<TApi>>;
45
45
  handler: {
46
46
  GET: (request: Request) => Promise<Response>;
47
+ OPTIONS: (request: Request) => Promise<Response>;
47
48
  POST: (request: Request) => Promise<Response>;
48
49
  };
49
50
  };
@@ -8,6 +8,7 @@ import { t as createCallerFactory } from "../../caller-factory-NEfgD5E0.js";
8
8
  * Next.js + Better Auth wrapper for Convex caller factory.
9
9
  */
10
10
  const TRAILING_COLON_RE = /:$/;
11
+ const requestCanHaveBody = (method) => method !== "GET" && method !== "HEAD" && method !== "OPTIONS";
11
12
  const handler = async (request, siteUrl) => {
12
13
  const requestUrl = new URL(request.url);
13
14
  const nextUrl = `${siteUrl}${requestUrl.pathname}${requestUrl.search}`;
@@ -18,7 +19,7 @@ const handler = async (request, siteUrl) => {
18
19
  headers.set("x-forwarded-proto", requestUrl.protocol.replace(TRAILING_COLON_RE, ""));
19
20
  headers.set("x-better-auth-forwarded-host", requestUrl.host);
20
21
  headers.set("x-better-auth-forwarded-proto", requestUrl.protocol.replace(TRAILING_COLON_RE, ""));
21
- const body = request.method !== "GET" && request.method !== "HEAD" ? await request.arrayBuffer() : void 0;
22
+ const body = requestCanHaveBody(request.method) ? await request.arrayBuffer() : void 0;
22
23
  return fetch(nextUrl, {
23
24
  body,
24
25
  headers,
@@ -28,6 +29,7 @@ const handler = async (request, siteUrl) => {
28
29
  };
29
30
  const nextJsHandler = (siteUrl) => ({
30
31
  GET: (request) => handler(request, siteUrl),
32
+ OPTIONS: (request) => handler(request, siteUrl),
31
33
  POST: (request) => handler(request, siteUrl)
32
34
  });
33
35
  /**
@@ -8926,7 +8926,7 @@ const styles = StyleSheet.create({
8926
8926
  //#region src/cli/registry/items/auth/auth-next-route.template.ts
8927
8927
  const AUTH_NEXT_ROUTE_TEMPLATE = `import { handler } from '@/lib/convex/server';
8928
8928
 
8929
- export const { GET, POST } = handler;
8929
+ export const { GET, POST, OPTIONS } = handler;
8930
8930
  `;
8931
8931
 
8932
8932
  //#endregion
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as promptForScaffoldTemplateSelection, A as resolveCodegenTrimSegments, At as highlighter, B as runConfiguredCodegen, C as isEntryPoint, Ct as formatDependencyInstallCommand, D as parseInitCommandArgs, E as parseBackendRunJson, Et as stripConvexCommandNoise, F as resolveRunDeps, G as runMigrationFlow, H as runDevSchemaBackfillIfNeeded, I as runAfterScaffoldScript, J as withWorkingDirectory, K as trackProcess, L as runAggregateBackfillFlow, M as resolveDocTopic, N as resolveInitProjectDir, O as readPackageVersions, P as resolveMigrationConfig, Q as promptForPluginSelection, R as runAggregatePruneFlow, S as isConvexDevPreRunConflictFlag, St as detectPackageManager, T as parseArgs, Tt as serializeEnvValue, U as runInitCommandFlow, V as runConvexInitIfNeeded, W as runMigrationCreate, X as collectPluginScaffoldTemplates, Y as createSpinner, Z as filterScaffoldTemplatePathMap, _ as formatInfoOutput, _t as applyPlanningDependencyInstall, a as cleanup, at as getPluginCatalogEntry, b as getDevAggregateBackfillStatePath, bt as resolveSupportedDependencyWarnings, c as createCommandEnv, ct as buildPluginInstallPlan, d as extractBackfillCliOptions, dt as collectInstalledPluginKeys, et as resolveAddTemplateDefaults, f as extractConcaveRunTargetArgs, ft as getPluginLockfilePath, g as formatDocsOutput, gt as applyDependencyHintsInstall, h as extractResetCliOptions, ht as resolveSchemaInstalledPlugins, i as buildInitializationPlan, it as resolveTemplatesByIdOrThrow, j as resolveConfiguredBackend, k as resolveBackfillConfig, kt as logger, l as ensureConvexGitignoreEntry, lt as resolvePluginScaffoldRoots, m as extractMigrationDownOptions, mt as readPluginLockfile, n as applyPluginInstallPlanFiles, nt as resolvePresetScaffoldTemplates, o as createBackendAdapter, ot as getSupportedPluginKeys, p as extractMigrationCliOptions, pt as getSchemaFilePath, q as withLocalCodegenEnv, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplateSelectionSource, s as createBackendCommandEnv, st as isSupportedPluginKey, t as applyDependencyInstallPlan, tt as resolvePluginPreset, u as extractBackendRunTargetArgs, ut as assertSchemaFileExists, v as getAggregateBackfillDeploymentKey, vt as applyPluginDependencyInstall, w as isInitialized, wt as resolveAuthEnvState, x as hasRemoteConvexDeploymentEnv, xt as resolveProjectScaffoldContext, y as getConvexDeploymentCommandEnv, yt as inspectPluginDependencyInstall, z as runBackendFunction } from "./backend-core-PsWKI66u.mjs";
2
+ import { $ as promptForScaffoldTemplateSelection, A as resolveCodegenTrimSegments, At as highlighter, B as runConfiguredCodegen, C as isEntryPoint, Ct as formatDependencyInstallCommand, D as parseInitCommandArgs, E as parseBackendRunJson, Et as stripConvexCommandNoise, F as resolveRunDeps, G as runMigrationFlow, H as runDevSchemaBackfillIfNeeded, I as runAfterScaffoldScript, J as withWorkingDirectory, K as trackProcess, L as runAggregateBackfillFlow, M as resolveDocTopic, N as resolveInitProjectDir, O as readPackageVersions, P as resolveMigrationConfig, Q as promptForPluginSelection, R as runAggregatePruneFlow, S as isConvexDevPreRunConflictFlag, St as detectPackageManager, T as parseArgs, Tt as serializeEnvValue, U as runInitCommandFlow, V as runConvexInitIfNeeded, W as runMigrationCreate, X as collectPluginScaffoldTemplates, Y as createSpinner, Z as filterScaffoldTemplatePathMap, _ as formatInfoOutput, _t as applyPlanningDependencyInstall, a as cleanup, at as getPluginCatalogEntry, b as getDevAggregateBackfillStatePath, bt as resolveSupportedDependencyWarnings, c as createCommandEnv, ct as buildPluginInstallPlan, d as extractBackfillCliOptions, dt as collectInstalledPluginKeys, et as resolveAddTemplateDefaults, f as extractConcaveRunTargetArgs, ft as getPluginLockfilePath, g as formatDocsOutput, gt as applyDependencyHintsInstall, h as extractResetCliOptions, ht as resolveSchemaInstalledPlugins, i as buildInitializationPlan, it as resolveTemplatesByIdOrThrow, j as resolveConfiguredBackend, k as resolveBackfillConfig, kt as logger, l as ensureConvexGitignoreEntry, lt as resolvePluginScaffoldRoots, m as extractMigrationDownOptions, mt as readPluginLockfile, n as applyPluginInstallPlanFiles, nt as resolvePresetScaffoldTemplates, o as createBackendAdapter, ot as getSupportedPluginKeys, p as extractMigrationCliOptions, pt as getSchemaFilePath, q as withLocalCodegenEnv, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplateSelectionSource, s as createBackendCommandEnv, st as isSupportedPluginKey, t as applyDependencyInstallPlan, tt as resolvePluginPreset, u as extractBackendRunTargetArgs, ut as assertSchemaFileExists, v as getAggregateBackfillDeploymentKey, vt as applyPluginDependencyInstall, w as isInitialized, wt as resolveAuthEnvState, x as hasRemoteConvexDeploymentEnv, xt as resolveProjectScaffoldContext, y as getConvexDeploymentCommandEnv, yt as inspectPluginDependencyInstall, z as runBackendFunction } from "./backend-core-CQmXi2Q0.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";
@@ -173,10 +173,18 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
173
173
  };
174
174
  }, Promise<any>>;
175
175
  deleteMany: convex_server0.RegisteredMutation<"internal", {
176
+ paginationOpts: {
177
+ id?: number;
178
+ endCursor?: string | null;
179
+ maximumRowsRead?: number;
180
+ maximumBytesRead?: number;
181
+ numItems: number;
182
+ cursor: string | null;
183
+ };
176
184
  input: {
177
185
  where?: {
186
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
178
187
  connector?: "AND" | "OR" | undefined;
179
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
180
188
  value: string | number | boolean | string[] | number[] | null;
181
189
  field: string;
182
190
  }[] | undefined;
@@ -185,14 +193,6 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
185
193
  where?: any[] | undefined;
186
194
  model: string;
187
195
  };
188
- paginationOpts: {
189
- id?: number;
190
- endCursor?: string | null;
191
- maximumRowsRead?: number;
192
- maximumBytesRead?: number;
193
- numItems: number;
194
- cursor: string | null;
195
- };
196
196
  }, Promise<{
197
197
  count: number;
198
198
  ids: any[];
@@ -204,8 +204,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
204
204
  deleteOne: convex_server0.RegisteredMutation<"internal", {
205
205
  input: {
206
206
  where?: {
207
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
207
208
  connector?: "AND" | "OR" | undefined;
208
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
209
209
  value: string | number | boolean | string[] | number[] | null;
210
210
  field: string;
211
211
  }[] | undefined;
@@ -216,21 +216,20 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
216
216
  };
217
217
  }, Promise<Record<string, unknown> | undefined>>;
218
218
  findMany: convex_server0.RegisteredQuery<"internal", {
219
+ limit?: number | undefined;
219
220
  join?: any;
220
221
  where?: {
221
222
  mode?: "sensitive" | "insensitive" | undefined;
223
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
222
224
  connector?: "AND" | "OR" | undefined;
223
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
224
225
  value: string | number | boolean | string[] | number[] | null;
225
226
  field: string;
226
227
  }[] | undefined;
227
- limit?: number | undefined;
228
228
  offset?: number | undefined;
229
229
  sortBy?: {
230
230
  field: string;
231
231
  direction: "asc" | "desc";
232
232
  } | undefined;
233
- model: string;
234
233
  paginationOpts: {
235
234
  id?: number;
236
235
  endCursor?: string | null;
@@ -239,47 +238,48 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
239
238
  numItems: number;
240
239
  cursor: string | null;
241
240
  };
241
+ model: string;
242
242
  }, Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>>;
243
243
  findOne: convex_server0.RegisteredQuery<"internal", {
244
244
  join?: any;
245
- select?: string[] | undefined;
246
245
  where?: {
247
246
  mode?: "sensitive" | "insensitive" | undefined;
247
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
248
248
  connector?: "AND" | "OR" | undefined;
249
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
250
249
  value: string | number | boolean | string[] | number[] | null;
251
250
  field: string;
252
251
  }[] | undefined;
252
+ select?: string[] | undefined;
253
253
  model: string;
254
254
  }, Promise<convex_server0.GenericDocument | null>>;
255
255
  getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
256
256
  rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
257
257
  updateMany: convex_server0.RegisteredMutation<"internal", {
258
+ paginationOpts: {
259
+ id?: number;
260
+ endCursor?: string | null;
261
+ maximumRowsRead?: number;
262
+ maximumBytesRead?: number;
263
+ numItems: number;
264
+ cursor: string | null;
265
+ };
258
266
  input: {
259
267
  where?: {
268
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
260
269
  connector?: "AND" | "OR" | undefined;
261
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
262
270
  value: string | number | boolean | string[] | number[] | null;
263
271
  field: string;
264
272
  }[] | undefined;
265
- model: string;
266
273
  update: {
267
274
  [x: string]: unknown;
268
275
  [x: number]: unknown;
269
276
  [x: symbol]: unknown;
270
277
  };
278
+ model: string;
271
279
  } | {
272
280
  where?: any[] | undefined;
273
- model: string;
274
281
  update: any;
275
- };
276
- paginationOpts: {
277
- id?: number;
278
- endCursor?: string | null;
279
- maximumRowsRead?: number;
280
- maximumBytesRead?: number;
281
- numItems: number;
282
- cursor: string | null;
282
+ model: string;
283
283
  };
284
284
  }, Promise<{
285
285
  count: number;
@@ -292,21 +292,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
292
292
  updateOne: convex_server0.RegisteredMutation<"internal", {
293
293
  input: {
294
294
  where?: {
295
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
295
296
  connector?: "AND" | "OR" | undefined;
296
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
297
297
  value: string | number | boolean | string[] | number[] | null;
298
298
  field: string;
299
299
  }[] | undefined;
300
- model: string;
301
300
  update: {
302
301
  [x: string]: unknown;
303
302
  [x: number]: unknown;
304
303
  [x: symbol]: unknown;
305
304
  };
305
+ model: string;
306
306
  } | {
307
307
  where?: any[] | undefined;
308
- model: string;
309
308
  update: any;
309
+ model: string;
310
310
  };
311
311
  }, Promise<any>>;
312
312
  };
@@ -1,4 +1,4 @@
1
- import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-DcEhkJ12.js";
1
+ import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-Dc58we_m.js";
2
2
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.js";
3
3
  import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CNo9ffvI.js";
4
4
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
package/dist/orm/index.js CHANGED
@@ -584,6 +584,71 @@ const deserializeFilterExpression = (expression) => {
584
584
  if (!nested) throw new Error("Serialized unary operand is missing.");
585
585
  return createUnaryExpression(unary.operator, nested);
586
586
  };
587
+ const PRIMARY_ID_LOOKUP_CURSOR_PREFIX = "kitcn:primary-id:";
588
+ const dedupePrimaryIds = (values) => Array.from(new Map(values.map((value) => [String(value), value])).values());
589
+ const parsePrimaryIdLookupCursor = (cursor) => {
590
+ if (cursor === null) return 0;
591
+ if (!cursor.startsWith(PRIMARY_ID_LOOKUP_CURSOR_PREFIX)) throw new Error("Invalid primary id mutation cursor.");
592
+ const offset = Number(cursor.slice(17));
593
+ if (!Number.isInteger(offset) || offset < 0) throw new Error("Invalid primary id mutation cursor.");
594
+ return offset;
595
+ };
596
+ const canUsePrimaryIdLookupCursor = (cursor) => cursor === null || cursor === void 0 || cursor.startsWith(PRIMARY_ID_LOOKUP_CURSOR_PREFIX);
597
+ const extractPrimaryIdLookup = (expression) => {
598
+ if (!expression || expression.type !== "binary") return null;
599
+ const binary = expression;
600
+ const [left, right] = binary.operands;
601
+ if (binary.operator === "eq") {
602
+ if (isFieldReference(left) && left.fieldName === "_id") {
603
+ if (isFieldReference(right)) return null;
604
+ return {
605
+ kind: "eq",
606
+ values: [right]
607
+ };
608
+ }
609
+ if (isFieldReference(right) && right.fieldName === "_id") {
610
+ if (isFieldReference(left)) return null;
611
+ return {
612
+ kind: "eq",
613
+ values: [left]
614
+ };
615
+ }
616
+ }
617
+ if (binary.operator === "inArray" && isFieldReference(left) && left.fieldName === "_id" && Array.isArray(right)) return {
618
+ kind: "in",
619
+ values: dedupePrimaryIds(right)
620
+ };
621
+ return null;
622
+ };
623
+ const windowPrimaryIdLookup = (lookup, pagination) => {
624
+ if (!pagination) return {
625
+ continueCursor: null,
626
+ isDone: true,
627
+ values: lookup.values
628
+ };
629
+ const offset = parsePrimaryIdLookupCursor(pagination.cursor);
630
+ const nextOffset = offset + pagination.limit;
631
+ const values = lookup.values.slice(offset, nextOffset);
632
+ const isDone = nextOffset >= lookup.values.length;
633
+ return {
634
+ continueCursor: isDone ? null : `${PRIMARY_ID_LOOKUP_CURSOR_PREFIX}${nextOffset}`,
635
+ isDone,
636
+ values
637
+ };
638
+ };
639
+ const collectPrimaryIdLookupRows = async (db, tableName, lookup, options) => {
640
+ if (!options.pagination && lookup.values.length > options.maxRows) throw new Error(`${options.operation} exceeded mutationMaxRows (${options.maxRows}) on "${tableName}". Narrow the filter or increase defineSchema(..., { defaults: { mutationMaxRows } }).`);
641
+ if (!options.pagination && lookup.values.length > options.batchSize) throw new Error(`${options.operation} matched more than mutationBatchSize (${options.batchSize}) primary ids on "${tableName}". Use executeAsync({ batchSize }) or paginate() to split the mutation.`);
642
+ const primaryIdWindow = windowPrimaryIdLookup(lookup, options.pagination);
643
+ if (primaryIdWindow.values.length > options.maxRows) throw new Error(`${options.operation} exceeded mutationMaxRows (${options.maxRows}) on "${tableName}". Narrow the filter or increase defineSchema(..., { defaults: { mutationMaxRows } }).`);
644
+ const normalizedIds = primaryIdWindow.values.filter((value) => value !== null && value !== void 0).map((value) => db.normalizeId(tableName, value)).filter((value) => value !== null);
645
+ const fetchedRows = await Promise.all(normalizedIds.map((value) => db.get(value)));
646
+ return {
647
+ continueCursor: primaryIdWindow.continueCursor,
648
+ isDone: primaryIdWindow.isDone,
649
+ rows: fetchedRows.filter((row) => !!row)
650
+ };
651
+ };
587
652
  const DEFAULT_MUTATION_BATCH_SIZE = 400;
588
653
  const DEFAULT_MUTATION_LEAF_BATCH_SIZE = 1600;
589
654
  const DEFAULT_MUTATION_MAX_ROWS = 1e4;
@@ -7431,27 +7496,6 @@ var ConvexDeleteBuilder = class extends QueryPromise {
7431
7496
  this.allowFullScanFlag = true;
7432
7497
  return this;
7433
7498
  }
7434
- getIdEquality() {
7435
- const expression = this.whereExpression;
7436
- if (!expression || expression.type !== "binary") return { matched: false };
7437
- if (expression.operator !== "eq") return { matched: false };
7438
- const [left, right] = expression.operands;
7439
- if (isFieldReference(left) && left.fieldName === "_id") {
7440
- if (isFieldReference(right)) return { matched: false };
7441
- return {
7442
- matched: true,
7443
- value: right
7444
- };
7445
- }
7446
- if (isFieldReference(right) && right.fieldName === "_id") {
7447
- if (isFieldReference(left)) return { matched: false };
7448
- return {
7449
- matched: true,
7450
- value: left
7451
- };
7452
- }
7453
- return { matched: false };
7454
- }
7455
7499
  soft() {
7456
7500
  this.deleteModeOverride = "soft";
7457
7501
  this.scheduledDelayMs = void 0;
@@ -7547,15 +7591,17 @@ var ConvexDeleteBuilder = class extends QueryPromise {
7547
7591
  let rows;
7548
7592
  let continueCursor = null;
7549
7593
  let isDone = true;
7550
- const idEquality = this.getIdEquality();
7551
- if (idEquality.matched) {
7552
- const idValue = idEquality.value;
7553
- if (isPaginated && pagination.cursor !== null) rows = [];
7554
- else if (idValue === null || idValue === void 0) rows = [];
7555
- else {
7556
- const row = await this.db.get(idValue);
7557
- rows = row ? [row] : [];
7558
- }
7594
+ const primaryIdLookup = canUsePrimaryIdLookupCursor(pagination?.cursor) ? extractPrimaryIdLookup(this.whereExpression) : null;
7595
+ if (primaryIdLookup) {
7596
+ const primaryIdRows = await collectPrimaryIdLookupRows(this.db, tableName, primaryIdLookup, {
7597
+ operation: "delete",
7598
+ pagination,
7599
+ batchSize,
7600
+ maxRows
7601
+ });
7602
+ continueCursor = primaryIdRows.continueCursor;
7603
+ isDone = primaryIdRows.isDone;
7604
+ rows = primaryIdRows.rows;
7559
7605
  } else if (this.whereExpression) {
7560
7606
  const compiled = new WhereClauseCompiler(tableName, getIndexes(this.table).map((index) => ({
7561
7607
  indexName: index.name,
@@ -8598,27 +8644,6 @@ var ConvexUpdateBuilder = class extends QueryPromise {
8598
8644
  this.allowFullScanFlag = true;
8599
8645
  return this;
8600
8646
  }
8601
- getIdEquality() {
8602
- const expression = this.whereExpression;
8603
- if (!expression || expression.type !== "binary") return { matched: false };
8604
- if (expression.operator !== "eq") return { matched: false };
8605
- const [left, right] = expression.operands;
8606
- if (isFieldReference(left) && left.fieldName === "_id") {
8607
- if (isFieldReference(right)) return { matched: false };
8608
- return {
8609
- matched: true,
8610
- value: right
8611
- };
8612
- }
8613
- if (isFieldReference(right) && right.fieldName === "_id") {
8614
- if (isFieldReference(left)) return { matched: false };
8615
- return {
8616
- matched: true,
8617
- value: left
8618
- };
8619
- }
8620
- return { matched: false };
8621
- }
8622
8647
  async executeAsync(...args) {
8623
8648
  const config = args[0];
8624
8649
  return this.execute({
@@ -8709,15 +8734,17 @@ var ConvexUpdateBuilder = class extends QueryPromise {
8709
8734
  let rows;
8710
8735
  let continueCursor = null;
8711
8736
  let isDone = true;
8712
- const idEquality = this.getIdEquality();
8713
- if (idEquality.matched) {
8714
- const idValue = idEquality.value;
8715
- if (isPaginated && pagination.cursor !== null) rows = [];
8716
- else if (idValue === null || idValue === void 0) rows = [];
8717
- else {
8718
- const row = await this.db.get(idValue);
8719
- rows = row ? [row] : [];
8720
- }
8737
+ const primaryIdLookup = canUsePrimaryIdLookupCursor(pagination?.cursor) ? extractPrimaryIdLookup(this.whereExpression) : null;
8738
+ if (primaryIdLookup) {
8739
+ const primaryIdRows = await collectPrimaryIdLookupRows(this.db, tableName, primaryIdLookup, {
8740
+ operation: "update",
8741
+ pagination,
8742
+ batchSize,
8743
+ maxRows
8744
+ });
8745
+ continueCursor = primaryIdRows.continueCursor;
8746
+ isDone = primaryIdRows.isDone;
8747
+ rows = primaryIdRows.rows;
8721
8748
  } else if (this.whereExpression) {
8722
8749
  const compiled = new WhereClauseCompiler(tableName, getIndexes(this.table).map((index) => ({
8723
8750
  indexName: index.name,
package/dist/watcher.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-PsWKI66u.mjs";
2
+ import { Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-CQmXi2Q0.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
@@ -2284,7 +2284,6 @@ declare class ConvexDeleteBuilder<TTable extends ConvexTable<any>, TReturning ex
2284
2284
  returning<TSelection extends ReturningSelection<TTable>>(fields: TSelection): ConvexDeleteWithout<ConvexDeleteBuilder<TTable, TSelection, TMode, THasWhereOrAllowFullScan>, 'returning'>;
2285
2285
  paginate(config: MutationPaginateConfig): ConvexDeleteWithout<ConvexDeleteBuilder<TTable, TReturning, 'paged', THasWhereOrAllowFullScan>, 'paginate'>;
2286
2286
  allowFullScan(): ConvexDeleteBuilder<TTable, TReturning, TMode, true>;
2287
- private getIdEquality;
2288
2287
  soft(): this;
2289
2288
  hard(): this;
2290
2289
  scheduled(config: {
@@ -2892,7 +2891,6 @@ declare class ConvexUpdateBuilder<TTable extends ConvexTable<any>, TReturning ex
2892
2891
  returning<TSelection extends ReturningSelection<TTable>>(fields: TSelection): ConvexUpdateWithout<ConvexUpdateBuilder<TTable, TSelection, TMode, THasWhereOrAllowFullScan>, 'returning'>;
2893
2892
  paginate(config: MutationPaginateConfig): ConvexUpdateWithout<ConvexUpdateBuilder<TTable, TReturning, 'paged', THasWhereOrAllowFullScan>, 'paginate'>;
2894
2893
  allowFullScan(): ConvexUpdateBuilder<TTable, TReturning, TMode, true>;
2895
- private getIdEquality;
2896
2894
  executeAsync(this: ConvexUpdateExecutableThis<TTable, TReturning, TMode>, ...args: TMode extends 'single' ? [config?: Omit<MutationExecuteConfig, 'mode'>] : [config: never]): Promise<TMode extends 'single' ? MutationExecuteResult<TTable, TReturning, 'single'> : never>;
2897
2895
  execute(this: ConvexUpdateExecutableThis<TTable, TReturning, TMode>, ...args: TMode extends 'single' ? [config?: MutationExecuteConfig] : [config?: never]): Promise<MutationExecuteResult<TTable, TReturning, TMode>>;
2898
2896
  }
@@ -3992,11 +3990,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3992
3990
  readonly aggregate_extrema: ConvexTableWithColumns<{
3993
3991
  name: "aggregate_extrema";
3994
3992
  columns: {
3995
- value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
3996
- _: {
3997
- $type: convex_values0.Value;
3998
- };
3999
- } & {
3993
+ count: ConvexNumberBuilderInitial<""> & {
4000
3994
  _: {
4001
3995
  notNull: true;
4002
3996
  };
@@ -4006,10 +4000,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4006
4000
  };
4007
4001
  } & {
4008
4002
  _: {
4009
- fieldName: "value";
4003
+ fieldName: "count";
4010
4004
  };
4011
4005
  };
4012
- count: ConvexNumberBuilderInitial<""> & {
4006
+ value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
4007
+ _: {
4008
+ $type: convex_values0.Value;
4009
+ };
4010
+ } & {
4013
4011
  _: {
4014
4012
  notNull: true;
4015
4013
  };
@@ -4019,7 +4017,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4019
4017
  };
4020
4018
  } & {
4021
4019
  _: {
4022
- fieldName: "count";
4020
+ fieldName: "value";
4023
4021
  };
4024
4022
  };
4025
4023
  updatedAt: ConvexNumberBuilderInitial<""> & {
@@ -4411,22 +4409,22 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4411
4409
  fieldName: "status";
4412
4410
  };
4413
4411
  };
4414
- cursor: ConvexTextBuilderInitial<""> & {
4412
+ direction: ConvexTextBuilderInitial<""> & {
4415
4413
  _: {
4416
4414
  tableName: "migration_state";
4417
4415
  };
4418
4416
  } & {
4419
4417
  _: {
4420
- fieldName: "cursor";
4418
+ fieldName: "direction";
4421
4419
  };
4422
4420
  };
4423
- direction: ConvexTextBuilderInitial<""> & {
4421
+ cursor: ConvexTextBuilderInitial<""> & {
4424
4422
  _: {
4425
4423
  tableName: "migration_state";
4426
4424
  };
4427
4425
  } & {
4428
4426
  _: {
4429
- fieldName: "direction";
4427
+ fieldName: "cursor";
4430
4428
  };
4431
4429
  };
4432
4430
  updatedAt: ConvexNumberBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -513,7 +513,7 @@ export const { createContext, createCaller, handler } = convexBetterAuth({
513
513
  |--------|-------------|
514
514
  | `createContext` | RSC context with auth |
515
515
  | `createCaller` | Server-side caller factory |
516
- | `handler` | Next.js API route handler (`export const { GET, POST } = handler;`) |
516
+ | `handler` | Next.js API route handler (`export const { GET, POST, OPTIONS } = handler;`) |
517
517
 
518
518
  Options: `api`, `convexSiteUrl`, `auth.jwtCache` (default true), `auth.isUnauthorized`.
519
519
 
@@ -530,7 +530,7 @@ return <ConvexProvider token={token}>{children}</ConvexProvider>;
530
530
  ```ts
531
531
  // src/app/api/auth/[...all]/route.ts
532
532
  import { handler } from '@/lib/convex/server';
533
- export const { GET, POST } = handler;
533
+ export const { GET, POST, OPTIONS } = handler;
534
534
  ```
535
535
 
536
536
  ---
@@ -23,7 +23,7 @@ export const { createContext, createCaller, handler } = convexBetterAuth({
23
23
  ```ts
24
24
  import { handler } from "@/lib/convex/server";
25
25
 
26
- export const { GET, POST } = handler;
26
+ export const { GET, POST, OPTIONS } = handler;
27
27
  ```
28
28
 
29
29
  ### 8.A.3 RSC helpers