kitcn 0.27.4 → 0.28.0

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.
@@ -2,16 +2,9 @@ import { r as omit } from "./upstream-BCgGZX6q.js";
2
2
  import { createAuthEndpoint, createAuthMiddleware, sessionMiddleware } from "better-auth/api";
3
3
  import { bearer } from "better-auth/plugins/bearer";
4
4
  import { jwt } from "better-auth/plugins/jwt";
5
- import { oidcProvider } from "better-auth/plugins/oidc-provider";
6
5
 
7
6
  //#region src/auth/internal/convex-plugin.ts
8
7
  const JWT_COOKIE_NAME = "convex_jwt";
9
- const normalizeAfterHooks = (hooks) => {
10
- return hooks.map((hook) => ({
11
- ...hook,
12
- matcher: (ctx) => Boolean(hook.matcher(ctx))
13
- }));
14
- };
15
8
  const getJwksAlg = (authProvider) => {
16
9
  const isCustomJwt = "type" in authProvider && authProvider.type === "customJwt";
17
10
  if (isCustomJwt && authProvider.algorithm !== "RS256") throw new Error("Only RS256 is supported for custom JWT with Better Auth");
@@ -28,27 +21,53 @@ const parseAuthConfig = (authConfig, opts) => {
28
21
  if (!isDataUriJwks && opts.jwks) console.warn("Static JWKS provided to Convex plugin, but not to auth config. This adds an unnecessary network request for token verification.");
29
22
  return providerConfig;
30
23
  };
31
- const oidcProviderCache = /* @__PURE__ */ new Map();
32
- const getOidcProvider = (basePath) => {
24
+ const createOpenIdConfig = (basePath, signingAlgorithm) => {
33
25
  const siteUrl = `${process.env.CONVEX_SITE_URL}`;
34
- const key = `${siteUrl}|${basePath}`;
35
- const cached = oidcProviderCache.get(key);
36
- if (cached) return cached;
37
- const oidcProvider$1 = oidcProvider({
38
- loginPage: "/not-used",
39
- metadata: {
40
- issuer: siteUrl,
41
- jwks_uri: `${siteUrl}${basePath}/convex/jwks`
42
- },
43
- __skipDeprecationWarning: true
44
- });
45
- oidcProviderCache.set(key, oidcProvider$1);
46
- return oidcProvider$1;
26
+ const baseUrl = `${siteUrl}${basePath}`;
27
+ return {
28
+ issuer: siteUrl,
29
+ authorization_endpoint: `${baseUrl}/oauth2/authorize`,
30
+ token_endpoint: `${baseUrl}/oauth2/token`,
31
+ userinfo_endpoint: `${baseUrl}/oauth2/userinfo`,
32
+ jwks_uri: `${baseUrl}/convex/jwks`,
33
+ registration_endpoint: `${baseUrl}/oauth2/register`,
34
+ end_session_endpoint: `${baseUrl}/oauth2/endsession`,
35
+ scopes_supported: [
36
+ "openid",
37
+ "profile",
38
+ "email",
39
+ "offline_access"
40
+ ],
41
+ response_types_supported: ["code"],
42
+ response_modes_supported: ["query"],
43
+ grant_types_supported: ["authorization_code", "refresh_token"],
44
+ acr_values_supported: ["urn:mace:incommon:iap:silver", "urn:mace:incommon:iap:bronze"],
45
+ subject_types_supported: ["public"],
46
+ id_token_signing_alg_values_supported: [signingAlgorithm],
47
+ token_endpoint_auth_methods_supported: [
48
+ "client_secret_basic",
49
+ "client_secret_post",
50
+ "none"
51
+ ],
52
+ code_challenge_methods_supported: ["S256"],
53
+ claims_supported: [
54
+ "sub",
55
+ "iss",
56
+ "aud",
57
+ "exp",
58
+ "nbf",
59
+ "iat",
60
+ "jti",
61
+ "email",
62
+ "email_verified",
63
+ "name"
64
+ ]
65
+ };
47
66
  };
48
67
  const convex = (opts) => {
49
68
  const jwtExpirationSeconds = opts.jwt?.expirationSeconds ?? opts.jwtExpirationSeconds ?? 900;
50
- const oidcProvider = getOidcProvider(opts.options?.basePath ?? "/api/auth");
51
- const providerConfig = parseAuthConfig(opts.authConfig, opts);
69
+ const signingAlgorithm = getJwksAlg(parseAuthConfig(opts.authConfig, opts));
70
+ const openIdConfig = createOpenIdConfig(opts.options?.basePath ?? "/api/auth", signingAlgorithm);
52
71
  const jwtOptions = {
53
72
  jwt: {
54
73
  issuer: `${process.env.CONVEX_SITE_URL}`,
@@ -63,7 +82,7 @@ const convex = (opts) => {
63
82
  iat: Math.floor(Date.now() / 1e3)
64
83
  })
65
84
  },
66
- jwks: { keyPairConfig: { alg: getJwksAlg(providerConfig) } }
85
+ jwks: { keyPairConfig: { alg: signingAlgorithm } }
67
86
  };
68
87
  const jwks = opts.jwks ? JSON.parse(opts.jwks) : void 0;
69
88
  const jwt$1 = jwt({
@@ -123,13 +142,14 @@ const convex = (opts) => {
123
142
  };
124
143
  ctx.context.internalAdapter.deleteSession = async (..._args) => {};
125
144
  const knownSafePaths = ["/api-key/list", "/api-key/get"];
126
- const noopWrite = (method) => {
145
+ const noopWrite = (method, result = 0) => {
127
146
  return async (..._args) => {
128
147
  if (ctx.path && !knownSafePaths.includes(ctx.path)) console.warn(`[convex-better-auth] Write operation "${method}" skipped in query context for ${ctx.path}`);
129
- return 0;
148
+ return result;
130
149
  };
131
150
  };
132
151
  ctx.context.adapter.create = noopWrite("create");
152
+ ctx.context.adapter.incrementOne = noopWrite("incrementOne", {});
133
153
  ctx.context.adapter.update = noopWrite("update");
134
154
  ctx.context.adapter.updateMany = noopWrite("updateMany");
135
155
  ctx.context.adapter.delete = noopWrite("delete");
@@ -137,53 +157,42 @@ const convex = (opts) => {
137
157
  return { context: ctx };
138
158
  })
139
159
  }],
140
- after: [
141
- ...normalizeAfterHooks(oidcProvider.hooks.after),
142
- {
143
- matcher: (ctx) => {
144
- return Boolean(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/oauth2/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/phone-number/verify") || ctx.path?.startsWith("/siwe/verify") || ctx.path?.startsWith("/update-session") || ctx.path?.startsWith("/get-session") && ctx.context.session);
145
- },
146
- handler: createAuthMiddleware(async (ctx) => {
147
- const originalSession = ctx.context.session;
148
- try {
149
- ctx.context.session = ctx.context.session ?? ctx.context.newSession;
150
- const { token } = await jwt$1.endpoints.getToken({
151
- ...ctx,
152
- asResponse: false,
153
- headers: {},
154
- method: "GET",
155
- returnHeaders: false,
156
- returnStatus: false
157
- });
158
- const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
159
- ctx.setCookie(jwtCookie.name, token, jwtCookie.attributes);
160
- } catch (_error) {}
161
- ctx.context.session = originalSession;
162
- })
160
+ after: [{
161
+ matcher: (ctx) => {
162
+ return Boolean(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/oauth2/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/phone-number/verify") || ctx.path?.startsWith("/siwe/verify") || ctx.path?.startsWith("/update-session") || ctx.path?.startsWith("/get-session") && ctx.context.session);
163
163
  },
164
- {
165
- matcher: (ctx) => {
166
- return Boolean(ctx.path?.startsWith("/sign-out") || ctx.path?.startsWith("/delete-user") || ctx.path?.startsWith("/get-session") && !ctx.context.session);
167
- },
168
- handler: createAuthMiddleware(async (ctx) => {
169
- const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: 0 });
170
- ctx.setCookie(jwtCookie.name, "", jwtCookie.attributes);
171
- })
172
- }
173
- ]
164
+ handler: createAuthMiddleware(async (ctx) => {
165
+ const originalSession = ctx.context.session;
166
+ try {
167
+ ctx.context.session = ctx.context.session ?? ctx.context.newSession;
168
+ const { token } = await jwt$1.endpoints.getToken({
169
+ ...ctx,
170
+ asResponse: false,
171
+ headers: {},
172
+ method: "GET",
173
+ returnHeaders: false,
174
+ returnStatus: false
175
+ });
176
+ const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
177
+ ctx.setCookie(jwtCookie.name, token, jwtCookie.attributes);
178
+ } catch (_error) {}
179
+ ctx.context.session = originalSession;
180
+ })
181
+ }, {
182
+ matcher: (ctx) => {
183
+ return Boolean(ctx.path?.startsWith("/sign-out") || ctx.path?.startsWith("/delete-user") || ctx.path?.startsWith("/get-session") && !ctx.context.session);
184
+ },
185
+ handler: createAuthMiddleware(async (ctx) => {
186
+ const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: 0 });
187
+ ctx.setCookie(jwtCookie.name, "", jwtCookie.attributes);
188
+ })
189
+ }]
174
190
  },
175
191
  endpoints: {
176
192
  getOpenIdConfig: createAuthEndpoint("/convex/.well-known/openid-configuration", {
177
193
  method: "GET",
178
194
  metadata: { isAction: false }
179
- }, async (ctx) => {
180
- return await oidcProvider.endpoints.getOpenIdConfig({
181
- ...ctx,
182
- asResponse: false,
183
- returnHeaders: false,
184
- returnStatus: false
185
- });
186
- }),
195
+ }, async () => openIdConfig),
187
196
  getJwks: createAuthEndpoint("/convex/jwks", {
188
197
  method: "GET",
189
198
  metadata: { openapi: {
@@ -111,8 +111,20 @@ const mergedIndexFields = (tables) => Object.fromEntries(Object.entries(tables).
111
111
  if (resolved.length === index.length) indexes.push(resolved);
112
112
  return indexes;
113
113
  }, []) || [];
114
- const specialFieldIndexes = Object.keys(specialFields(tables)[key] || {}).filter((index) => !manualIndexes.some((m) => Array.isArray(m) ? m[0] === index : m === index));
115
- return [key, manualIndexes.concat(specialFieldIndexes)];
114
+ const declaredIndexes = (table.indexes ?? []).reduce((indexes, index) => {
115
+ const resolved = index.fields.map((fieldKey) => resolveIndexField(fieldKey)).filter((fieldName) => fieldName !== null);
116
+ if (resolved.length === index.fields.length) indexes.push(resolved.length === 1 ? resolved[0] : resolved);
117
+ return indexes;
118
+ }, []);
119
+ const explicitIndexes = manualIndexes.concat(declaredIndexes);
120
+ const specialFieldIndexes = Object.keys(specialFields(tables)[key] || {}).filter((index) => !explicitIndexes.some((m) => Array.isArray(m) ? m[0] === index : m === index));
121
+ const seen = /* @__PURE__ */ new Set();
122
+ return [key, explicitIndexes.concat(specialFieldIndexes).filter((index) => {
123
+ const key = (Array.isArray(index) ? index : [index]).join("\0");
124
+ if (seen.has(key)) return false;
125
+ seen.add(key);
126
+ return true;
127
+ })];
116
128
  }));
117
129
  const createSchema = async ({ exportName = "tables", file, regenerateCommand, tables }) => {
118
130
  const path = await import(Buffer.from("cGF0aA==", "base64").toString());
@@ -143,7 +155,7 @@ export const ${exportName} = {
143
155
  }[type];
144
156
  }
145
157
  const indexes = mergedIndexFields(tables)[tableKey]?.map((index) => {
146
- const indexArray = Array.isArray(index) ? index.sort() : [index];
158
+ const indexArray = Array.isArray(index) ? index : [index];
147
159
  return `.index("${indexArray.join("_")}", ${JSON.stringify(indexArray)})`;
148
160
  }) || [];
149
161
  const schema = `${modelName}: defineTable({
@@ -1,4 +1,4 @@
1
- import { augmentBetterAuthTables, indexFields } from "./create-schema-DqhLA_UF.js";
1
+ import { augmentBetterAuthTables, indexFields } from "./create-schema-ojI-OH_9.js";
2
2
 
3
3
  //#region src/auth/create-schema-orm.ts
4
4
  const specialFields = (tables) => Object.fromEntries(Object.entries(tables).map(([key, table]) => {
@@ -24,8 +24,20 @@ const mergedIndexFields = (tables) => Object.fromEntries(Object.entries(tables).
24
24
  if (resolved.length === index.length) indexes.push(resolved);
25
25
  return indexes;
26
26
  }, []) || [];
27
- const specialFieldIndexes = Object.entries(tableSpecialFields).filter(([, fieldMeta]) => fieldMeta.unique !== true).map(([fieldName]) => fieldName).filter((index) => !manualIndexes.some((m) => Array.isArray(m) ? m[0] === index : m === index));
28
- return [key, manualIndexes.concat(specialFieldIndexes)];
27
+ const declaredIndexes = (table.indexes ?? []).reduce((indexes, index) => {
28
+ const resolved = index.fields.map((fieldKey) => resolveIndexField(fieldKey)).filter((fieldName) => fieldName !== null);
29
+ if (resolved.length === index.fields.length) indexes.push(resolved.length === 1 ? resolved[0] : resolved);
30
+ return indexes;
31
+ }, []);
32
+ const explicitIndexes = manualIndexes.concat(declaredIndexes);
33
+ const specialFieldIndexes = Object.entries(tableSpecialFields).filter(([, fieldMeta]) => fieldMeta.unique !== true).map(([fieldName]) => fieldName).filter((index) => !explicitIndexes.some((m) => Array.isArray(m) ? m[0] === index : m === index));
34
+ const seen = /* @__PURE__ */ new Set();
35
+ return [key, explicitIndexes.concat(specialFieldIndexes).filter((index) => {
36
+ const key = (Array.isArray(index) ? index : [index]).join("\0");
37
+ if (seen.has(key)) return false;
38
+ seen.add(key);
39
+ return true;
40
+ })];
29
41
  }));
30
42
  const VALID_IDENTIFIER_REGEX = /^[$A-Z_][0-9A-Z_$]*$/i;
31
43
  const LEADING_DIGIT_REGEX = /^[0-9]/;
@@ -175,11 +187,19 @@ const renderSchemaOrmFile = async ({ extensionKey, exportName, file, mode, regen
175
187
  return ` ${key}: ${expression},`;
176
188
  });
177
189
  const indexes = mergedIndexFields(tables)[entry.key]?.map((indexSpec) => {
178
- const indexArray = Array.isArray(indexSpec) ? [...indexSpec].sort() : [indexSpec];
190
+ const indexArray = Array.isArray(indexSpec) ? indexSpec : [indexSpec];
179
191
  const indexName = indexArray.join("_");
180
- state.ormImports.add("index");
192
+ const indexFactory = (entry.table.indexes ?? []).some((index) => {
193
+ if (!index.unique) return false;
194
+ const resolvedFields = index.fields.map((fieldKey) => {
195
+ const field = entry.table.fields[fieldKey];
196
+ return field ? field.fieldName ?? fieldKey : null;
197
+ }).filter((fieldName) => fieldName !== null);
198
+ return resolvedFields.length === index.fields.length && resolvedFields.join("\0") === indexArray.join("\0");
199
+ }) ? "uniqueIndex" : "index";
200
+ state.ormImports.add(indexFactory);
181
201
  const fieldsCall = indexArray.map((fieldName) => renderPropertyAccess(entry.varName, fieldName)).join(", ");
182
- return `index(${JSON.stringify(indexName)}).on(${fieldsCall})`;
202
+ return `${indexFactory}(${JSON.stringify(indexName)}).on(${fieldsCall})`;
183
203
  }) || [];
184
204
  const extraConfig = indexes.length > 0 ? `,\n (${entry.varName}) => [\n ${indexes.join(",\n ")},\n ]` : "";
185
205
  tableBlocks.push(`export const ${entry.varName} = convexTable(\n ${JSON.stringify(entry.modelName)},\n {\n${fieldLines.join("\n")}\n }${extraConfig}\n);`);
@@ -113,6 +113,16 @@ declare const updateOneHandler: (ctx: any, args: {
113
113
  tableTriggers?: RuntimeTableTriggers;
114
114
  triggerCtx?: unknown;
115
115
  }, schema: Schema, betterAuthSchema: any) => Promise<any>;
116
+ declare const incrementOneHandler: (ctx: any, args: {
117
+ input: {
118
+ increment: Record<string, number>;
119
+ model: string;
120
+ set?: Record<string, unknown>;
121
+ where?: any[];
122
+ };
123
+ tableTriggers?: RuntimeTableTriggers;
124
+ triggerCtx?: unknown;
125
+ }, schema: Schema, betterAuthSchema: any) => Promise<any>;
116
126
  declare const updateManyHandler: (ctx: any, args: {
117
127
  input: {
118
128
  model: string;
@@ -130,14 +140,16 @@ declare const updateManyHandler: (ctx: any, args: {
130
140
  splitCursor?: convex_server0.Cursor | null;
131
141
  pageStatus?: "SplitRecommended" | "SplitRequired" | null;
132
142
  }>;
133
- declare const deleteOneHandler: (ctx: any, args: {
143
+ type DeleteOneArgs = {
134
144
  input: {
135
145
  model: string;
136
146
  where?: any[];
137
147
  };
138
148
  tableTriggers?: RuntimeTableTriggers;
139
149
  triggerCtx?: unknown;
140
- }, schema: Schema, betterAuthSchema: any) => Promise<Record<string, unknown> | undefined>;
150
+ };
151
+ declare const deleteOneHandler: (ctx: any, args: DeleteOneArgs, schema: Schema, betterAuthSchema: any) => Promise<Record<string, unknown> | undefined>;
152
+ declare const consumeOneHandler: (ctx: any, args: DeleteOneArgs, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.GenericDocument | null>;
141
153
  declare const deleteManyHandler: (ctx: any, args: {
142
154
  input: {
143
155
  model: string;
@@ -166,6 +178,20 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
166
178
  triggers?: GenericAuthTriggers<DataModel, Schema, TriggerCtx> | ((ctx: TriggerCtx) => GenericAuthTriggers<DataModel, Schema, TriggerCtx> | undefined); /** Validate input validators against auth table schemas. Defaults to false for smaller generated types. */
167
179
  validateInput?: boolean;
168
180
  }) => {
181
+ consumeOne: convex_server0.RegisteredMutation<"internal", {
182
+ input: {
183
+ where?: {
184
+ connector?: "AND" | "OR" | undefined;
185
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
186
+ field: string;
187
+ value: string | number | boolean | string[] | number[] | null;
188
+ }[] | undefined;
189
+ model: string;
190
+ } | {
191
+ where?: any[] | undefined;
192
+ model: string;
193
+ };
194
+ }, Promise<convex_server0.GenericDocument | null>>;
169
195
  create: convex_server0.RegisteredMutation<"internal", {
170
196
  select?: string[] | undefined;
171
197
  input: {
@@ -185,8 +211,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
185
211
  where?: {
186
212
  connector?: "AND" | "OR" | undefined;
187
213
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
188
- value: string | number | boolean | string[] | number[] | null;
189
214
  field: string;
215
+ value: string | number | boolean | string[] | number[] | null;
190
216
  }[] | undefined;
191
217
  model: string;
192
218
  } | {
@@ -214,8 +240,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
214
240
  where?: {
215
241
  connector?: "AND" | "OR" | undefined;
216
242
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
217
- value: string | number | boolean | string[] | number[] | null;
218
243
  field: string;
244
+ value: string | number | boolean | string[] | number[] | null;
219
245
  }[] | undefined;
220
246
  model: string;
221
247
  } | {
@@ -224,19 +250,19 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
224
250
  };
225
251
  }, Promise<Record<string, unknown> | undefined>>;
226
252
  findMany: convex_server0.RegisteredQuery<"internal", {
253
+ limit?: number | undefined;
227
254
  join?: any;
228
255
  where?: {
229
256
  mode?: "sensitive" | "insensitive" | undefined;
230
257
  connector?: "AND" | "OR" | undefined;
231
258
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
232
- value: string | number | boolean | string[] | number[] | null;
233
259
  field: string;
260
+ value: string | number | boolean | string[] | number[] | null;
234
261
  }[] | undefined;
235
- limit?: number | undefined;
236
262
  offset?: number | undefined;
237
263
  sortBy?: {
238
- direction: "asc" | "desc";
239
264
  field: string;
265
+ direction: "asc" | "desc";
240
266
  } | undefined;
241
267
  model: string;
242
268
  paginationOpts: {
@@ -250,25 +276,39 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
250
276
  }, Promise<PaginationResult<convex_server0.GenericDocument>>>;
251
277
  findOne: convex_server0.RegisteredQuery<"internal", {
252
278
  join?: any;
253
- select?: string[] | undefined;
254
279
  where?: {
255
280
  mode?: "sensitive" | "insensitive" | undefined;
256
281
  connector?: "AND" | "OR" | undefined;
257
282
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
258
- value: string | number | boolean | string[] | number[] | null;
259
283
  field: string;
284
+ value: string | number | boolean | string[] | number[] | null;
260
285
  }[] | undefined;
286
+ select?: string[] | undefined;
261
287
  model: string;
262
288
  }, Promise<convex_server0.GenericDocument | null>>;
263
289
  getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
290
+ incrementOne: convex_server0.RegisteredMutation<"internal", {
291
+ input: {
292
+ set?: Record<string, any> | undefined;
293
+ where?: {
294
+ mode?: "sensitive" | "insensitive" | undefined;
295
+ connector?: "AND" | "OR" | undefined;
296
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
297
+ field: string;
298
+ value: string | number | boolean | string[] | number[] | null;
299
+ }[] | undefined;
300
+ model: string;
301
+ increment: Record<string, number>;
302
+ };
303
+ }, Promise<any>>;
264
304
  rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
265
305
  updateMany: convex_server0.RegisteredMutation<"internal", {
266
306
  input: {
267
307
  where?: {
268
308
  connector?: "AND" | "OR" | undefined;
269
309
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
270
- value: string | number | boolean | string[] | number[] | null;
271
310
  field: string;
311
+ value: string | number | boolean | string[] | number[] | null;
272
312
  }[] | undefined;
273
313
  model: string;
274
314
  update: {
@@ -302,8 +342,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
302
342
  where?: {
303
343
  connector?: "AND" | "OR" | undefined;
304
344
  operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
305
- value: string | number | boolean | string[] | number[] | null;
306
345
  field: string;
346
+ value: string | number | boolean | string[] | number[] | null;
307
347
  }[] | undefined;
308
348
  model: string;
309
349
  update: {
@@ -321,11 +361,13 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
321
361
  //#endregion
322
362
  //#region src/auth/create-client.d.ts
323
363
  type AuthFunctions = {
364
+ consumeOne: FunctionReference<'mutation', 'internal', Record<string, any>>;
324
365
  create: FunctionReference<'mutation', 'internal', Record<string, any>>;
325
366
  deleteMany: FunctionReference<'mutation', 'internal', Record<string, any>>;
326
367
  deleteOne: FunctionReference<'mutation', 'internal', Record<string, any>>;
327
368
  findMany: FunctionReference<'query', 'internal', Record<string, any>>;
328
369
  findOne: FunctionReference<'query', 'internal', Record<string, any>>;
370
+ incrementOne: FunctionReference<'mutation', 'internal', Record<string, any>>;
329
371
  updateMany: FunctionReference<'mutation', 'internal', Record<string, any>>;
330
372
  updateOne: FunctionReference<'mutation', 'internal', Record<string, any>>;
331
373
  };
@@ -366,4 +408,4 @@ declare const createDisabledAuthRuntime: <DataModel extends GenericDataModel, Sc
366
408
  reason?: string;
367
409
  }) => AuthRuntime<DataModel, Schema, TriggerCtx, GenericCtx, AuthOptions>;
368
410
  //#endregion
369
- export { defineAuth as S, GenericAuthBeforeResult as _, AuthFunctions as a, GenericAuthTriggerHandlers as b, createApi as c, deleteOneHandler as d, findManyHandler as f, BetterAuthOptionsWithoutDatabase as g, updateOneHandler as h, getGeneratedAuthDisabledReason as i, createHandler as l, updateManyHandler as m, GeneratedAuthDisabledReasonKind as n, Triggers as o, findOneHandler as p, createDisabledAuthRuntime as r, createClient as s, AuthRuntime as t, deleteManyHandler as u, GenericAuthDefinition as v, GenericAuthTriggers as x, GenericAuthTriggerChange as y };
411
+ export { GenericAuthTriggers as C, GenericAuthTriggerHandlers as S, updateOneHandler as _, AuthFunctions as a, GenericAuthDefinition as b, consumeOneHandler as c, deleteManyHandler as d, deleteOneHandler as f, updateManyHandler as g, incrementOneHandler as h, getGeneratedAuthDisabledReason as i, createApi as l, findOneHandler as m, GeneratedAuthDisabledReasonKind as n, Triggers as o, findManyHandler as p, createDisabledAuthRuntime as r, createClient as s, AuthRuntime as t, createHandler as u, BetterAuthOptionsWithoutDatabase as v, defineAuth as w, GenericAuthTriggerChange as x, GenericAuthBeforeResult as y };
@@ -34,11 +34,13 @@ const createDisabledAuthRuntime = (config) => {
34
34
  throw new Error(`${message} (auth)`);
35
35
  } }),
36
36
  getAuth: createDisabledError(message, "getAuth"),
37
+ consumeOne: createDisabledRuntimeExport(message, "consumeOne"),
37
38
  create: createDisabledRuntimeExport(message, "create"),
38
39
  deleteMany: createDisabledRuntimeExport(message, "deleteMany"),
39
40
  deleteOne: createDisabledRuntimeExport(message, "deleteOne"),
40
41
  findMany: createDisabledRuntimeExport(message, "findMany"),
41
42
  findOne: createDisabledRuntimeExport(message, "findOne"),
43
+ incrementOne: createDisabledRuntimeExport(message, "incrementOne"),
42
44
  updateMany: createDisabledRuntimeExport(message, "updateMany"),
43
45
  updateOne: createDisabledRuntimeExport(message, "updateOne"),
44
46
  getLatestJwks: createDisabledRuntimeExport(message, "getLatestJwks"),
@@ -1,4 +1,4 @@
1
- import { $ as RankOrderField, G as CountBackfillKickoffArgs, J as AggregateQueryPlan, K as CountBackfillMode, Q as RankIndexDefinition, W as CountBackfillChunkArgs, X as AggregateIndexDefinition, Y as CountQueryPlan, Z as CountIndexDefinition, q as CountBackfillStatusArgs, r as OrmCapability } from "../../capabilities-CLCYgRdY.js";
1
+ import { $ as RankOrderField, G as CountBackfillKickoffArgs, J as AggregateQueryPlan, K as CountBackfillMode, Q as RankIndexDefinition, W as CountBackfillChunkArgs, X as AggregateIndexDefinition, Y as CountQueryPlan, Z as CountIndexDefinition, q as CountBackfillStatusArgs, r as OrmCapability } from "../../capabilities-DkfnnNp7.js";
2
2
 
3
3
  //#region src/orm/aggregate-index/capability.d.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import { t as DirectAggregate } from "../../runtime-CcOvOf4K.js";
2
2
  import { a as Columns } from "../../table-CX2lnX7e.js";
3
- import { Ct as usesSystemCreatedAtAlias, St as PUBLIC_CREATED_AT_FIELD, Z as normalizeTemporalComparableValue, a as AGGREGATE_STATE_TABLE, c as getAggregateIndexDefinitions, d as COUNT_ERROR, dt as mapWithConcurrency, i as AGGREGATE_RANK_TREE_TABLE, l as getRankIndexDefinitions, m as createError, n as AGGREGATE_EXTREMA_TABLE, r as AGGREGATE_MEMBER_TABLE, s as rankAggregateName, t as AGGREGATE_BUCKET_TABLE, u as AGGREGATE_ERROR, xt as INTERNAL_CREATION_TIME_FIELD } from "../../schema-C5WWEqsj.js";
3
+ import { Et as usesSystemCreatedAtAlias, Tt as PUBLIC_CREATED_AT_FIELD, Z as normalizeTemporalComparableValue, a as AGGREGATE_STATE_TABLE, c as getAggregateIndexDefinitions, d as COUNT_ERROR, i as AGGREGATE_RANK_TREE_TABLE, l as getRankIndexDefinitions, m as createError, mt as mapWithConcurrency, n as AGGREGATE_EXTREMA_TABLE, r as AGGREGATE_MEMBER_TABLE, s as rankAggregateName, t as AGGREGATE_BUCKET_TABLE, u as AGGREGATE_ERROR, wt as INTERNAL_CREATION_TIME_FIELD } from "../../schema-D95Z3Kss.js";
4
4
 
5
5
  //#region src/orm/aggregate-index/runtime.ts
6
6
  const UNDEFINED_SENTINEL = "__kitcnUndefined";
@@ -1,5 +1,5 @@
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-CLCYgRdY.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-DAPEBp1y.js";
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-DkfnnNp7.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-CETRjurp.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";