kitcn 0.27.5 → 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,15 +250,15 @@ 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
264
  field: string;
@@ -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,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-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-DuC8Nr7e.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";
@@ -1,3 +1,3 @@
1
1
  import { C as MigrationTableName, D as defineMigrationSet, E as defineMigration, O as detectMigrationDrift, S as MigrationStep, T as buildMigrationPlan, _ as MigrationMigrateOne, a as MigrationCancelArgs, b as MigrationSet, c as MigrationStatusArgs, d as MigrationDefinition, f as MigrationDirection, g as MigrationManifestEntry, h as MigrationDriftIssue, l as createMigrationHandlers, m as MigrationDocContext, o as MigrationRunArgs, p as MigrationDoc, s as MigrationRunChunkArgs, u as MigrationAppliedState, v as MigrationPlan, w as MigrationWriteMode, x as MigrationStateMap, y as MigrationRunStatus } from "../../capabilities-DkfnnNp7.js";
2
- import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-DuC8Nr7e.js";
2
+ import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-CETRjurp.js";
3
3
  export { MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
@@ -8,8 +8,6 @@ import { BetterAuthClientPlugin } from "better-auth/client";
8
8
  import { createAuthClient } from "better-auth/solid";
9
9
  import * as better_auth0 from "better-auth";
10
10
  import { Session, User } from "better-auth";
11
- import * as better_auth_api0 from "better-auth/api";
12
- import * as better_auth_plugins_oidc_provider0 from "better-auth/plugins/oidc-provider";
13
11
  import * as jose from "jose";
14
12
  import { BetterAuthOptions } from "better-auth/minimal";
15
13
 
@@ -977,18 +975,15 @@ declare const convex$1: (opts: {
977
975
  hooks: {
978
976
  before: ({
979
977
  matcher(context: better_auth0.HookEndpointContext): boolean;
980
- handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
978
+ handler: better_auth0.Middleware<better_auth0.MiddlewareOptions, (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
981
979
  context: {
982
980
  headers: Headers;
983
981
  };
984
- } | undefined>;
982
+ } | undefined>>;
985
983
  } | {
986
984
  matcher: (ctx: better_auth0.HookEndpointContext) => boolean;
987
- handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
988
- context: better_auth0.MiddlewareContext<better_auth0.MiddlewareOptions, {
989
- returned?: unknown | undefined;
990
- responseHeaders?: Headers | undefined;
991
- } & better_auth0.PluginContext<BetterAuthOptions> & better_auth0.InfoContext & {
985
+ handler: better_auth0.Middleware<better_auth0.MiddlewareOptions, (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
986
+ context: better_auth0.MiddlewareContext<better_auth0.MiddlewareOptions, better_auth0.PluginContext<BetterAuthOptions> & better_auth0.InfoContext & {
992
987
  options: BetterAuthOptions;
993
988
  trustedOrigins: string[];
994
989
  trustedProviders: string[];
@@ -1080,6 +1075,7 @@ declare const convex$1: (opts: {
1080
1075
  updateAge: number;
1081
1076
  expiresIn: number;
1082
1077
  freshAge: number;
1078
+ cookieCacheSigner?: better_auth0.CookieCacheSigner | undefined;
1083
1079
  cookieRefreshCache: false | {
1084
1080
  enabled: true;
1085
1081
  updateAge: number;
@@ -1113,12 +1109,15 @@ declare const convex$1: (opts: {
1113
1109
  skipCSRFCheck: boolean;
1114
1110
  runInBackground: (promise: Promise<unknown>) => void;
1115
1111
  runInBackgroundOrAwait: (promise: Promise<unknown> | void) => better_auth0.Awaitable<unknown>;
1112
+ } & {
1113
+ returned?: unknown | undefined;
1114
+ responseHeaders?: Headers | undefined;
1116
1115
  }>;
1117
- }>;
1116
+ }>>;
1118
1117
  })[];
1119
1118
  after: {
1120
- matcher: (context: better_auth0.HookEndpointContext) => boolean;
1121
- handler: better_auth_api0.AuthMiddleware;
1119
+ matcher: (ctx: better_auth0.HookEndpointContext) => boolean;
1120
+ handler: better_auth0.Middleware<better_auth0.MiddlewareOptions, (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>>;
1122
1121
  }[];
1123
1122
  };
1124
1123
  endpoints: {
@@ -1127,7 +1126,25 @@ declare const convex$1: (opts: {
1127
1126
  metadata: {
1128
1127
  isAction: false;
1129
1128
  };
1130
- }, better_auth_plugins_oidc_provider0.OIDCMetadata>;
1129
+ }, {
1130
+ issuer: string;
1131
+ authorization_endpoint: string;
1132
+ token_endpoint: string;
1133
+ userinfo_endpoint: string;
1134
+ jwks_uri: string;
1135
+ registration_endpoint: string;
1136
+ end_session_endpoint: string;
1137
+ scopes_supported: string[];
1138
+ response_types_supported: string[];
1139
+ response_modes_supported: string[];
1140
+ grant_types_supported: string[];
1141
+ acr_values_supported: string[];
1142
+ subject_types_supported: string[];
1143
+ id_token_signing_alg_values_supported: string[];
1144
+ token_endpoint_auth_methods_supported: string[];
1145
+ code_challenge_methods_supported: string[];
1146
+ claims_supported: string[];
1147
+ }>;
1131
1148
  getJwks: better_auth0.StrictEndpoint<"/convex/jwks", {
1132
1149
  method: "GET";
1133
1150
  metadata: {
@@ -1164,7 +1181,7 @@ declare const convex$1: (opts: {
1164
1181
  getToken: better_auth0.StrictEndpoint<"/convex/token", {
1165
1182
  method: "GET";
1166
1183
  requireHeaders: true;
1167
- use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
1184
+ use: better_auth0.Middleware<better_auth0.MiddlewareOptions, (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
1168
1185
  session: {
1169
1186
  session: Record<string, any> & {
1170
1187
  id: string;
@@ -1186,7 +1203,7 @@ declare const convex$1: (opts: {
1186
1203
  image?: string | null | undefined;
1187
1204
  };
1188
1205
  };
1189
- }>)[];
1206
+ }>>[];
1190
1207
  metadata: {
1191
1208
  openapi: {
1192
1209
  description: string;
@@ -1215,6 +1232,14 @@ declare const convex$1: (opts: {
1215
1232
  type: "date";
1216
1233
  required: false;
1217
1234
  };
1235
+ alg: {
1236
+ type: "string";
1237
+ required: false;
1238
+ };
1239
+ crv: {
1240
+ type: "string";
1241
+ required: false;
1242
+ };
1218
1243
  };
1219
1244
  };
1220
1245
  user: {
@@ -1288,7 +1313,10 @@ type SolidAuthProviderClient = {
1288
1313
  type AuthClientWithPlugins<Plugins extends BetterAuthClientPlugin[]> = ReturnType<typeof createAuthClient<{
1289
1314
  plugins: Plugins;
1290
1315
  }>>;
1291
- type SolidAuthClient = AuthClientWithPlugins<PluginsWithCrossDomain> | AuthClientWithPlugins<PluginsWithoutCrossDomain>;
1316
+ type HydratableAuthClient<Plugins extends BetterAuthClientPlugin[]> = Omit<AuthClientWithPlugins<Plugins>, 'hydrateSession'> & {
1317
+ hydrateSession(session: Parameters<AuthClientWithPlugins<Plugins>['hydrateSession']>[0]): void;
1318
+ };
1319
+ type SolidAuthClient = HydratableAuthClient<PluginsWithCrossDomain> | HydratableAuthClient<PluginsWithoutCrossDomain>;
1292
1320
  //#endregion
1293
1321
  //#region src/solid/convex-auth-provider.d.ts
1294
1322
  type ConvexAuthProviderProps = {
@@ -1,4 +1,4 @@
1
- import { t as JWT_COOKIE_NAME } from "./convex-plugin-DfOhBU9g.js";
1
+ import { t as JWT_COOKIE_NAME } from "./convex-plugin-Dic0l-k8.js";
2
2
  import { betterFetch } from "@better-fetch/fetch";
3
3
  import { getSessionCookie } from "better-auth/cookies";
4
4
  import * as jose from "jose";