better-convex 0.9.0 → 0.9.2

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,7 @@
1
- import { Dt as ConvexCustomBuilderInitial, _t as ConvexNumberBuilderInitial, bt as ConvexIdBuilderInitial, qn as ConvexTextBuilderInitial, rn as ConvexTableWithColumns } from "../where-clause-compiler-UavDdMUX.js";
1
+ import "../validators-BcQFm1oY.js";
2
+ import { Jn as ConvexTextBuilderInitial, Ot as ConvexCustomBuilderInitial, in as ConvexTableWithColumns, vt as ConvexNumberBuilderInitial, xt as ConvexIdBuilderInitial } from "../where-clause-compiler-DjFwXrQn.js";
3
+ import "../query-context-ji7By8u0.js";
4
+ import "../orm/index.js";
2
5
  import * as convex_values0 from "convex/values";
3
6
  import { GenericId, Infer, Value } from "convex/values";
4
7
  import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
@@ -107,48 +107,69 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
107
107
  authStore
108
108
  ]);
109
109
  const fetchAccessToken = useCallback(async ({ forceRefreshToken = false } = {}) => {
110
+ const fetchFreshToken = () => {
111
+ if (pendingTokenRef.current) return pendingTokenRef.current;
112
+ pendingTokenRef.current = authClient.convex.token({ fetchOptions: { throw: false } }).then((result) => {
113
+ const jwt = result.data?.token || null;
114
+ if (jwt) {
115
+ const exp = decodeJwtExp(jwt);
116
+ authStore.set("token", jwt);
117
+ authStore.set("expiresAt", exp);
118
+ return jwt;
119
+ }
120
+ authStore.set("token", null);
121
+ authStore.set("expiresAt", null);
122
+ return null;
123
+ }).catch((error) => {
124
+ authStore.set("token", null);
125
+ authStore.set("expiresAt", null);
126
+ console.error("[fetchAccessToken] error", error);
127
+ return null;
128
+ }).finally(() => {
129
+ pendingTokenRef.current = null;
130
+ });
131
+ return pendingTokenRef.current;
132
+ };
133
+ const fetchFreshTokenForced = async () => {
134
+ if (pendingTokenRef.current) {
135
+ const token = await pendingTokenRef.current;
136
+ if (token) return token;
137
+ }
138
+ return fetchFreshToken();
139
+ };
110
140
  const currentSession = sessionRef.current;
111
141
  const currentIsPending = isPendingRef.current;
112
142
  if (!hasActiveSessionData(currentSession)) {
113
- if (!currentIsPending) {
114
- authStore.set("token", null);
115
- authStore.set("expiresAt", null);
143
+ if (currentIsPending) {
144
+ if (!forceRefreshToken) return authStore.get("token");
145
+ const cachedToken = authStore.get("token");
146
+ const freshToken = await fetchFreshTokenForced();
147
+ if (!freshToken && cachedToken) {
148
+ authStore.set("token", cachedToken);
149
+ authStore.set("expiresAt", decodeJwtExp(cachedToken));
150
+ return cachedToken;
151
+ }
152
+ return freshToken;
116
153
  }
117
- return authStore.get("token");
154
+ authStore.set("token", null);
155
+ authStore.set("expiresAt", null);
156
+ return null;
118
157
  }
119
- const cachedToken = authStore.get("token");
158
+ const cachedToken_0 = authStore.get("token");
120
159
  const expiresAt = authStore.get("expiresAt");
121
160
  const timeRemaining = expiresAt ? expiresAt - Date.now() : 0;
122
- if (!forceRefreshToken && cachedToken && expiresAt && timeRemaining >= 6e4) return cachedToken;
161
+ if (!forceRefreshToken && cachedToken_0 && expiresAt && timeRemaining >= 6e4) return cachedToken_0;
123
162
  if (!forceRefreshToken && pendingTokenRef.current) return pendingTokenRef.current;
124
- pendingTokenRef.current = authClient.convex.token({ fetchOptions: { throw: false } }).then((result) => {
125
- const jwt = result.data?.token || null;
126
- if (jwt) {
127
- const exp = decodeJwtExp(jwt);
128
- authStore.set("token", jwt);
129
- authStore.set("expiresAt", exp);
130
- return jwt;
131
- }
132
- authStore.set("token", null);
133
- authStore.set("expiresAt", null);
134
- return null;
135
- }).catch((error) => {
136
- authStore.set("token", null);
137
- authStore.set("expiresAt", null);
138
- console.error("[fetchAccessToken] error", error);
139
- return null;
140
- }).finally(() => {
141
- pendingTokenRef.current = null;
142
- });
143
- return pendingTokenRef.current;
163
+ if (forceRefreshToken) return fetchFreshTokenForced();
164
+ return fetchFreshToken();
144
165
  }, [authStore, authClient]);
145
166
  const useAuth = useCallback(function useConvexAuthHook() {
146
- const token = authStore.get("token");
167
+ const token_0 = authStore.get("token");
147
168
  const hasSession_0 = hasActiveSessionData(sessionRef.current);
148
169
  const sessionMissing = !hasSession_0 && !isPendingRef.current;
149
170
  return {
150
- isLoading: isPendingRef.current && !token,
151
- isAuthenticated: sessionMissing ? false : hasSession_0 || token !== null,
171
+ isLoading: isPendingRef.current && !token_0,
172
+ isAuthenticated: sessionMissing ? false : hasSession_0 || token_0 !== null,
152
173
  fetchAccessToken
153
174
  };
154
175
  }, [fetchAccessToken, authStore]);
@@ -1,6 +1,7 @@
1
+ import "../validators-BcQFm1oY.js";
1
2
  import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-ji7By8u0.js";
2
3
  import { t as GetAuth } from "../types-CM67ko7K.js";
3
- import { A as GenericCtx } from "../procedure-caller-DYjpq7rG.js";
4
+ import { A as GenericCtx } from "../procedure-caller-kZJx_hmP.js";
4
5
  import "../http-types-BK7FuIcR.js";
5
6
  import "../server/index.js";
6
7
  import * as convex_values0 from "convex/values";
@@ -182,28 +183,28 @@ type AdapterPaginationOptions = PaginationOptions & {
182
183
  };
183
184
  declare const adapterWhereValidator: convex_values0.VObject<{
184
185
  connector?: "AND" | "OR" | undefined;
185
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
186
- field: string;
186
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
187
187
  value: string | number | boolean | string[] | number[] | null;
188
+ field: string;
188
189
  }, {
189
190
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
190
191
  field: convex_values0.VString<string, "required">;
191
- 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>;
192
+ operator: convex_values0.VUnion<"in" | "lt" | "lte" | "gt" | "gte" | "eq" | "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>;
192
193
  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>;
193
- }, "required", "connector" | "field" | "operator" | "value">;
194
+ }, "required", "value" | "connector" | "field" | "operator">;
194
195
  declare const adapterArgsValidator: convex_values0.VObject<{
195
196
  limit?: number | undefined;
196
197
  select?: string[] | undefined;
197
198
  offset?: number | undefined;
198
199
  sortBy?: {
199
- field: string;
200
200
  direction: "asc" | "desc";
201
+ field: string;
201
202
  } | undefined;
202
203
  where?: {
203
204
  connector?: "AND" | "OR" | undefined;
204
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
205
- field: string;
205
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
206
206
  value: string | number | boolean | string[] | number[] | null;
207
+ field: string;
207
208
  }[] | undefined;
208
209
  model: string;
209
210
  }, {
@@ -212,29 +213,29 @@ declare const adapterArgsValidator: convex_values0.VObject<{
212
213
  offset: convex_values0.VFloat64<number | undefined, "optional">;
213
214
  select: convex_values0.VArray<string[] | undefined, convex_values0.VString<string, "required">, "optional">;
214
215
  sortBy: convex_values0.VObject<{
215
- field: string;
216
216
  direction: "asc" | "desc";
217
+ field: string;
217
218
  } | undefined, {
218
219
  direction: convex_values0.VUnion<"asc" | "desc", [convex_values0.VLiteral<"asc", "required">, convex_values0.VLiteral<"desc", "required">], "required", never>;
219
220
  field: convex_values0.VString<string, "required">;
220
- }, "optional", "field" | "direction">;
221
+ }, "optional", "direction" | "field">;
221
222
  where: convex_values0.VArray<{
222
223
  connector?: "AND" | "OR" | undefined;
223
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
224
- field: string;
224
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
225
225
  value: string | number | boolean | string[] | number[] | null;
226
+ field: string;
226
227
  }[] | undefined, convex_values0.VObject<{
227
228
  connector?: "AND" | "OR" | undefined;
228
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
229
- field: string;
229
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
230
230
  value: string | number | boolean | string[] | number[] | null;
231
+ field: string;
231
232
  }, {
232
233
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
233
234
  field: convex_values0.VString<string, "required">;
234
- 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>;
235
+ operator: convex_values0.VUnion<"in" | "lt" | "lte" | "gt" | "gte" | "eq" | "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>;
235
236
  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>;
236
- }, "required", "connector" | "field" | "operator" | "value">, "optional">;
237
- }, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.field" | "sortBy.direction">;
237
+ }, "required", "value" | "connector" | "field" | "operator">, "optional">;
238
+ }, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.direction" | "sortBy.field">;
238
239
  declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
239
240
  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>;
240
241
  declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => Promise<D | null>;
@@ -359,26 +360,26 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
359
360
  };
360
361
  }, Promise<any>>;
361
362
  deleteMany: convex_server0.RegisteredMutation<"internal", {
362
- paginationOpts: {
363
- id?: number;
364
- endCursor?: string | null;
365
- maximumRowsRead?: number;
366
- maximumBytesRead?: number;
367
- numItems: number;
368
- cursor: string | null;
369
- };
370
363
  input: {
371
364
  where?: {
372
365
  connector?: "AND" | "OR" | undefined;
373
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
374
- field: string;
366
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
375
367
  value: string | number | boolean | string[] | number[] | null;
368
+ field: string;
376
369
  }[] | undefined;
377
370
  model: string;
378
371
  } | {
379
372
  where?: any[] | undefined;
380
373
  model: string;
381
374
  };
375
+ paginationOpts: {
376
+ id?: number;
377
+ endCursor?: string | null;
378
+ maximumRowsRead?: number;
379
+ maximumBytesRead?: number;
380
+ numItems: number;
381
+ cursor: string | null;
382
+ };
382
383
  }, Promise<{
383
384
  count: number;
384
385
  ids: any[];
@@ -391,9 +392,9 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
391
392
  input: {
392
393
  where?: {
393
394
  connector?: "AND" | "OR" | undefined;
394
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
395
- field: string;
395
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
396
396
  value: string | number | boolean | string[] | number[] | null;
397
+ field: string;
397
398
  }[] | undefined;
398
399
  model: string;
399
400
  } | {
@@ -406,14 +407,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
406
407
  join?: any;
407
408
  offset?: number | undefined;
408
409
  sortBy?: {
409
- field: string;
410
410
  direction: "asc" | "desc";
411
+ field: string;
411
412
  } | undefined;
412
413
  where?: {
413
414
  connector?: "AND" | "OR" | undefined;
414
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
415
- field: string;
415
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
416
416
  value: string | number | boolean | string[] | number[] | null;
417
+ field: string;
417
418
  }[] | undefined;
418
419
  paginationOpts: {
419
420
  id?: number;
@@ -430,27 +431,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
430
431
  select?: string[] | undefined;
431
432
  where?: {
432
433
  connector?: "AND" | "OR" | undefined;
433
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
434
- field: string;
434
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
435
435
  value: string | number | boolean | string[] | number[] | null;
436
+ field: string;
436
437
  }[] | undefined;
437
438
  model: string;
438
439
  }, Promise<convex_server0.GenericDocument | null>>;
440
+ getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
441
+ rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
439
442
  updateMany: convex_server0.RegisteredMutation<"internal", {
440
- paginationOpts: {
441
- id?: number;
442
- endCursor?: string | null;
443
- maximumRowsRead?: number;
444
- maximumBytesRead?: number;
445
- numItems: number;
446
- cursor: string | null;
447
- };
448
443
  input: {
449
444
  where?: {
450
445
  connector?: "AND" | "OR" | undefined;
451
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
452
- field: string;
446
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
453
447
  value: string | number | boolean | string[] | number[] | null;
448
+ field: string;
454
449
  }[] | undefined;
455
450
  update: {
456
451
  [x: string]: unknown;
@@ -463,6 +458,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
463
458
  update: any;
464
459
  model: string;
465
460
  };
461
+ paginationOpts: {
462
+ id?: number;
463
+ endCursor?: string | null;
464
+ maximumRowsRead?: number;
465
+ maximumBytesRead?: number;
466
+ numItems: number;
467
+ cursor: string | null;
468
+ };
466
469
  }, Promise<{
467
470
  count: number;
468
471
  ids: any[];
@@ -475,9 +478,9 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
475
478
  input: {
476
479
  where?: {
477
480
  connector?: "AND" | "OR" | undefined;
478
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
479
- field: string;
481
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
480
482
  value: string | number | boolean | string[] | number[] | null;
483
+ field: string;
481
484
  }[] | undefined;
482
485
  update: {
483
486
  [x: string]: unknown;
@@ -491,8 +494,6 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
491
494
  model: string;
492
495
  };
493
496
  }, Promise<any>>;
494
- getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
495
- rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
496
497
  };
497
498
  //#endregion
498
499
  //#region ../../node_modules/kysely/dist/esm/operation-node/operation-node.d.ts
@@ -19155,26 +19156,26 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19155
19156
  };
19156
19157
  }, Promise<any>>;
19157
19158
  deleteMany: convex_server0.RegisteredMutation<"internal", {
19158
- paginationOpts: {
19159
- id?: number;
19160
- endCursor?: string | null;
19161
- maximumRowsRead?: number;
19162
- maximumBytesRead?: number;
19163
- numItems: number;
19164
- cursor: string | null;
19165
- };
19166
19159
  input: {
19167
19160
  where?: {
19168
19161
  connector?: "AND" | "OR" | undefined;
19169
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19170
- field: string;
19162
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19171
19163
  value: string | number | boolean | string[] | number[] | null;
19164
+ field: string;
19172
19165
  }[] | undefined;
19173
19166
  model: string;
19174
19167
  } | {
19175
19168
  where?: any[] | undefined;
19176
19169
  model: string;
19177
19170
  };
19171
+ paginationOpts: {
19172
+ id?: number;
19173
+ endCursor?: string | null;
19174
+ maximumRowsRead?: number;
19175
+ maximumBytesRead?: number;
19176
+ numItems: number;
19177
+ cursor: string | null;
19178
+ };
19178
19179
  }, Promise<{
19179
19180
  count: number;
19180
19181
  ids: any[];
@@ -19187,9 +19188,9 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19187
19188
  input: {
19188
19189
  where?: {
19189
19190
  connector?: "AND" | "OR" | undefined;
19190
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19191
- field: string;
19191
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19192
19192
  value: string | number | boolean | string[] | number[] | null;
19193
+ field: string;
19193
19194
  }[] | undefined;
19194
19195
  model: string;
19195
19196
  } | {
@@ -19202,14 +19203,14 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19202
19203
  join?: any;
19203
19204
  offset?: number | undefined;
19204
19205
  sortBy?: {
19205
- field: string;
19206
19206
  direction: "asc" | "desc";
19207
+ field: string;
19207
19208
  } | undefined;
19208
19209
  where?: {
19209
19210
  connector?: "AND" | "OR" | undefined;
19210
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19211
- field: string;
19211
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19212
19212
  value: string | number | boolean | string[] | number[] | null;
19213
+ field: string;
19213
19214
  }[] | undefined;
19214
19215
  paginationOpts: {
19215
19216
  id?: number;
@@ -19226,27 +19227,21 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19226
19227
  select?: string[] | undefined;
19227
19228
  where?: {
19228
19229
  connector?: "AND" | "OR" | undefined;
19229
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19230
- field: string;
19230
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19231
19231
  value: string | number | boolean | string[] | number[] | null;
19232
+ field: string;
19232
19233
  }[] | undefined;
19233
19234
  model: string;
19234
19235
  }, Promise<convex_server0.GenericDocument | null>>;
19236
+ getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
19237
+ rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
19235
19238
  updateMany: convex_server0.RegisteredMutation<"internal", {
19236
- paginationOpts: {
19237
- id?: number;
19238
- endCursor?: string | null;
19239
- maximumRowsRead?: number;
19240
- maximumBytesRead?: number;
19241
- numItems: number;
19242
- cursor: string | null;
19243
- };
19244
19239
  input: {
19245
19240
  where?: {
19246
19241
  connector?: "AND" | "OR" | undefined;
19247
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19248
- field: string;
19242
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19249
19243
  value: string | number | boolean | string[] | number[] | null;
19244
+ field: string;
19250
19245
  }[] | undefined;
19251
19246
  update: {
19252
19247
  [x: string]: unknown;
@@ -19259,6 +19254,14 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19259
19254
  update: any;
19260
19255
  model: string;
19261
19256
  };
19257
+ paginationOpts: {
19258
+ id?: number;
19259
+ endCursor?: string | null;
19260
+ maximumRowsRead?: number;
19261
+ maximumBytesRead?: number;
19262
+ numItems: number;
19263
+ cursor: string | null;
19264
+ };
19262
19265
  }, Promise<{
19263
19266
  count: number;
19264
19267
  ids: any[];
@@ -19271,9 +19274,9 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19271
19274
  input: {
19272
19275
  where?: {
19273
19276
  connector?: "AND" | "OR" | undefined;
19274
- operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19275
- field: string;
19277
+ operator?: "in" | "lt" | "lte" | "gt" | "gte" | "eq" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
19276
19278
  value: string | number | boolean | string[] | number[] | null;
19279
+ field: string;
19277
19280
  }[] | undefined;
19278
19281
  update: {
19279
19282
  [x: string]: unknown;
@@ -19287,8 +19290,6 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
19287
19290
  model: string;
19288
19291
  };
19289
19292
  }, Promise<any>>;
19290
- getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
19291
- rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
19292
19293
  authEnabled: true;
19293
19294
  authClient: {
19294
19295
  authFunctions: AuthFunctions;
@@ -315,7 +315,7 @@ const resolveOrmTable = (ctx, schema, betterAuthSchema, model) => {
315
315
  const tableName = resolveSchemaTableName(schema, betterAuthSchema, model);
316
316
  if (!tableName) return;
317
317
  const table = schema.tables[tableName];
318
- if (!table || !table._id) return;
318
+ if (!table?._id) return;
319
319
  return {
320
320
  table,
321
321
  tableName
@@ -409,10 +409,19 @@ const serializeDatesForConvex = (value) => {
409
409
  return serialized ?? value;
410
410
  };
411
411
  const toConvexSafe = (value) => serializeDatesForConvex(value);
412
+ const withAuthTimestamps = (data) => {
413
+ if (data.createdAt !== void 0) return data;
414
+ const now = Date.now();
415
+ return {
416
+ ...data,
417
+ createdAt: now,
418
+ ...data.updatedAt === void 0 ? { updatedAt: now } : {}
419
+ };
420
+ };
412
421
  const createHandler = async (ctx, args, schema, betterAuthSchema) => {
413
422
  const triggerCtx = args.triggerCtx ?? ctx;
414
423
  const tableTriggers = args.tableTriggers;
415
- const data = serializeDatesForConvex(await applyBeforeHook(args.input.model, "create", args.input.data, tableTriggers?.create?.before, triggerCtx));
424
+ const data = serializeDatesForConvex(withAuthTimestamps(await applyBeforeHook(args.input.model, "create", args.input.data, tableTriggers?.create?.before, triggerCtx)));
416
425
  await checkUniqueFields(ctx, schema, betterAuthSchema, args.input.model, data);
417
426
  const ormTable = resolveOrmTable(ctx, schema, betterAuthSchema, args.input.model);
418
427
  const doc = ormTable ? await ormInsert(ctx, ormTable.table, data) : await (async () => {
@@ -639,6 +648,7 @@ const createApi = (schema, getAuth, options) => {
639
648
  }),
640
649
  findMany: internalQueryGeneric({
641
650
  args: {
651
+ join: v.optional(v.any()),
642
652
  limit: v.optional(v.number()),
643
653
  model: modelValidator,
644
654
  offset: v.optional(v.number()),
@@ -647,20 +657,31 @@ const createApi = (schema, getAuth, options) => {
647
657
  direction: v.union(v.literal("asc"), v.literal("desc")),
648
658
  field: v.string()
649
659
  })),
650
- where: v.optional(v.array(adapterWhereValidator)),
651
- join: v.optional(v.any())
660
+ where: v.optional(v.array(adapterWhereValidator))
652
661
  },
653
662
  handler: async (ctx, args) => findManyHandler(ctx, args, schema, getBetterAuthSchema())
654
663
  }),
655
664
  findOne: internalQueryGeneric({
656
665
  args: {
666
+ join: v.optional(v.any()),
657
667
  model: modelValidator,
658
668
  select: v.optional(v.array(v.string())),
659
- where: v.optional(v.array(adapterWhereValidator)),
660
- join: v.optional(v.any())
669
+ where: v.optional(v.array(adapterWhereValidator))
661
670
  },
662
671
  handler: async (ctx, args) => findOneHandler(ctx, args, schema, getBetterAuthSchema())
663
672
  }),
673
+ getLatestJwks: internalActionGeneric({
674
+ args: {},
675
+ handler: async (ctx) => {
676
+ return getAuth(ctx).api.getLatestJwks();
677
+ }
678
+ }),
679
+ rotateKeys: internalActionGeneric({
680
+ args: {},
681
+ handler: async (ctx) => {
682
+ return getAuth(ctx).api.rotateKeys();
683
+ }
684
+ }),
664
685
  updateMany: mutationBuilder({
665
686
  args: {
666
687
  input: updateInput,
@@ -686,18 +707,6 @@ const createApi = (schema, getAuth, options) => {
686
707
  triggerCtx
687
708
  }, schema, getBetterAuthSchema());
688
709
  }
689
- }),
690
- getLatestJwks: internalActionGeneric({
691
- args: {},
692
- handler: async (ctx) => {
693
- return getAuth(ctx).api.getLatestJwks();
694
- }
695
- }),
696
- rotateKeys: internalActionGeneric({
697
- args: {},
698
- handler: async (ctx) => {
699
- return getAuth(ctx).api.rotateKeys();
700
- }
701
710
  })
702
711
  };
703
712
  };
@@ -1,4 +1,5 @@
1
- import { B as ConvexContext, H as LazyCaller } from "../../procedure-caller-DYjpq7rG.js";
1
+ import "../../validators-BcQFm1oY.js";
2
+ import { B as ConvexContext, H as LazyCaller } from "../../procedure-caller-kZJx_hmP.js";
2
3
  import "../../http-types-BK7FuIcR.js";
3
4
  import "../../server/index.js";
4
5
  import { GetTokenOptions } from "@convex-dev/better-auth/utils";
@@ -12,7 +13,8 @@ type AuthOptions = {
12
13
  };
13
14
  type ConvexBetterAuthOptions<TApi> = Omit<GetTokenOptions, 'jwtCache'> & {
14
15
  api: TApi;
15
- convexSiteUrl: string; /** Auth options. JWT caching is enabled by default (set `auth.jwtCache: false` to disable). */
16
+ convexSiteUrl: string;
17
+ convexUrl?: string; /** Auth options. JWT caching is enabled by default (set `auth.jwtCache: false` to disable). */
16
18
  auth?: AuthOptions;
17
19
  };
18
20
  /**
@@ -38,10 +40,10 @@ type ConvexBetterAuthOptions<TApi> = Omit<GetTokenOptions, 'jwtCache'> & {
38
40
  * ```
39
41
  */
40
42
  declare function convexBetterAuth<TApi extends Record<string, unknown>>(opts: ConvexBetterAuthOptions<TApi>): {
43
+ createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
41
44
  createContext: (reqOpts: {
42
45
  headers: Headers;
43
46
  }) => Promise<ConvexContext<TApi>>;
44
- createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
45
47
  handler: {
46
48
  GET: (request: Request) => Promise<Response>;
47
49
  POST: (request: Request) => Promise<Response>;
@@ -1,5 +1,5 @@
1
1
  import { n as defaultIsUnauthorized } from "../../error-CAGGSN5H.js";
2
- import { t as createCallerFactory } from "../../caller-factory-CCsm4Dut.js";
2
+ import { t as createCallerFactory } from "../../caller-factory-C1uAqm5w.js";
3
3
  import { getToken } from "@convex-dev/better-auth/utils";
4
4
 
5
5
  //#region src/auth-nextjs/index.ts
@@ -50,7 +50,6 @@ function convexBetterAuth(opts) {
50
50
  const jwtCacheEnabled = auth.jwtCache !== false;
51
51
  const { createContext, createCaller } = createCallerFactory({
52
52
  api: opts.api,
53
- convexSiteUrl: opts.convexSiteUrl,
54
53
  auth: jwtCacheEnabled ? {
55
54
  getToken: (siteUrl, headers, getTokenOpts) => {
56
55
  const mutableHeaders = new Headers(headers);
@@ -66,11 +65,13 @@ function convexBetterAuth(opts) {
66
65
  });
67
66
  },
68
67
  isUnauthorized: auth.isUnauthorized ?? defaultIsUnauthorized
69
- } : void 0
68
+ } : void 0,
69
+ convexSiteUrl: opts.convexSiteUrl,
70
+ convexUrl: opts.convexUrl
70
71
  });
71
72
  return {
72
- createContext,
73
73
  createCaller,
74
+ createContext,
74
75
  handler: nextJsHandler(opts.convexSiteUrl)
75
76
  };
76
77
  }
@@ -116,12 +116,20 @@ function createLazyCaller(api, createContext) {
116
116
  * Framework-agnostic caller factory.
117
117
  * getToken is passed as a parameter - decoupled from @convex-dev/better-auth.
118
118
  */
119
- const getArgsAndOptions = (args, token) => [args[0], { token }];
119
+ const CONVEX_SITE_URL_RE = /\.convex\.site(?=\/|$)/;
120
+ const getArgsAndOptions = (args, token, url) => [args[0], {
121
+ token,
122
+ url
123
+ }];
120
124
  const parseConvexSiteUrl = (url) => {
121
125
  if (!url) throw new Error("CONVEX_SITE_URL is not set. This must be set in the environment.");
122
126
  if (url.endsWith(".convex.cloud")) throw new Error(`CONVEX_SITE_URL should end in .convex.site, not .convex.cloud. Currently set to ${url}.`);
123
127
  return url;
124
128
  };
129
+ const getConvexUrl = (siteUrl, convexUrl) => {
130
+ if (convexUrl) return convexUrl;
131
+ return siteUrl.replace(CONVEX_SITE_URL_RE, ".convex.cloud");
132
+ };
125
133
  /**
126
134
  * Framework-agnostic caller factory.
127
135
  *
@@ -137,6 +145,7 @@ const parseConvexSiteUrl = (url) => {
137
145
  const noAuthGetToken = () => Promise.resolve({ token: void 0 });
138
146
  function createCallerFactory(opts) {
139
147
  const siteUrl = parseConvexSiteUrl(opts.convexSiteUrl);
148
+ const convexUrl = getConvexUrl(siteUrl, opts.convexUrl);
140
149
  const getToken = opts.auth?.getToken ?? noAuthGetToken;
141
150
  const isUnauthorized = opts.auth?.isUnauthorized;
142
151
  const crpcMeta = buildMetaIndex(opts.api);
@@ -166,40 +175,40 @@ function createCallerFactory(opts) {
166
175
  const fetchAuthQuery = async (query, args, callerOpts) => {
167
176
  if (callerOpts?.skipUnauth && !tokenResult.token) return null;
168
177
  return callWithTokenAndRetry((token) => {
169
- const argsAndOptions = getArgsAndOptions([args], token);
178
+ const argsAndOptions = getArgsAndOptions([args], token, convexUrl);
170
179
  return fetchQuery(query, argsAndOptions[0], argsAndOptions[1]);
171
180
  }, tokenResult, reqOpts.headers);
172
181
  };
173
182
  const fetchAuthMutation = async (mutation, args, callerOpts) => {
174
183
  if (callerOpts?.skipUnauth && !tokenResult.token) return null;
175
184
  return callWithTokenAndRetry((token) => {
176
- const argsAndOptions = getArgsAndOptions([args], token);
185
+ const argsAndOptions = getArgsAndOptions([args], token, convexUrl);
177
186
  return fetchMutation(mutation, argsAndOptions[0], argsAndOptions[1]);
178
187
  }, tokenResult, reqOpts.headers);
179
188
  };
180
189
  const fetchAuthAction = async (action, args, callerOpts) => {
181
190
  if (callerOpts?.skipUnauth && !tokenResult.token) return null;
182
191
  return callWithTokenAndRetry((token) => {
183
- const argsAndOptions = getArgsAndOptions([args], token);
192
+ const argsAndOptions = getArgsAndOptions([args], token, convexUrl);
184
193
  return fetchAction(action, argsAndOptions[0], argsAndOptions[1]);
185
194
  }, tokenResult, reqOpts.headers);
186
195
  };
187
196
  return {
188
- token: tokenResult.token,
189
- isAuthenticated: !!tokenResult.token,
190
197
  caller: createServerCaller(opts.api, {
191
- fetchQuery: fetchAuthQuery,
192
- fetchMutation: fetchAuthMutation,
193
198
  fetchAction: fetchAuthAction,
199
+ fetchMutation: fetchAuthMutation,
200
+ fetchQuery: fetchAuthQuery,
194
201
  meta: crpcMeta,
195
202
  transformer: opts.transformer
196
- })
203
+ }),
204
+ isAuthenticated: !!tokenResult.token,
205
+ token: tokenResult.token
197
206
  };
198
207
  };
199
208
  const createCaller = (ctxFn) => createLazyCaller(opts.api, ctxFn);
200
209
  return {
201
- createContext,
202
- createCaller
210
+ createCaller,
211
+ createContext
203
212
  };
204
213
  }
205
214
 
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as getConvexConfig, t as generateMeta } from "./codegen-BS36cYTH.mjs";
2
+ import { n as getConvexConfig, t as generateMeta } from "./codegen-CMQIKrqh.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash } from "node:crypto";
5
5
  import fs from "node:fs";
@@ -531,17 +531,22 @@ const listConvexHandlerExports = async (entryPoint, jitiInstance) => {
531
531
  return Array.from(exportNames).sort((a, b) => a.localeCompare(b));
532
532
  };
533
533
  const scanHandlerExportsByEntry = async (entryPoints) => {
534
- const jitiInstance = createJiti(process.cwd(), {
535
- interopDefault: true,
536
- moduleCache: false
537
- });
538
- const results = await Promise.all(entryPoints.map(async (entryPoint) => ({
539
- entryPoint,
540
- exportNames: await listConvexHandlerExports(entryPoint, jitiInstance)
541
- })));
542
- const byEntry = /* @__PURE__ */ new Map();
543
- for (const result of results) if (result.exportNames.length > 0) byEntry.set(result.entryPoint, result.exportNames);
544
- return byEntry;
534
+ globalThis.__BETTER_CONVEX_CODEGEN__ = true;
535
+ try {
536
+ const jitiInstance = createJiti(process.cwd(), {
537
+ interopDefault: true,
538
+ moduleCache: false
539
+ });
540
+ const results = await Promise.all(entryPoints.map(async (entryPoint) => ({
541
+ entryPoint,
542
+ exportNames: await listConvexHandlerExports(entryPoint, jitiInstance)
543
+ })));
544
+ const byEntry = /* @__PURE__ */ new Map();
545
+ for (const result of results) if (result.exportNames.length > 0) byEntry.set(result.entryPoint, result.exportNames);
546
+ return byEntry;
547
+ } finally {
548
+ delete globalThis.__BETTER_CONVEX_CODEGEN__;
549
+ }
545
550
  };
546
551
  const parseArgs$1 = (argv) => {
547
552
  const options = {
@@ -888,40 +888,45 @@ async function generateMeta(outputDir, options) {
888
888
  if (hasTriggersExport && !hasRelationsExport) throw new Error("Codegen error: schema.ts exports 'triggers' but is missing 'relations'. Export `relations` and define triggers via `defineTriggers(relations, { ... })`.");
889
889
  ensureGeneratedSupportPlaceholders(functionsDir, { includeAuth: generateAuth });
890
890
  if (generateApi) {
891
- const jitiInstance = createJiti(process.cwd(), {
892
- interopDefault: true,
893
- moduleCache: false
894
- });
895
- const files = listFilesRecursive(functionsDir).filter((file) => file.endsWith(".ts") && isValidConvexFile(file));
896
- createdRuntimePlaceholders = ensureGeneratedRuntimePlaceholders(functionsDir, [...new Set([
897
- ...files.map((file) => file.replace(TS_EXTENSION_RE, "")),
898
- ...hasRelationsExport ? ["generated/server"] : [],
899
- ...generateAuth ? [generatedAuthModuleName] : []
900
- ])]);
901
- for (const file of files) {
902
- const filePath = path.join(functionsDir, file);
903
- const moduleName = file.replace(TS_EXTENSION_RE, "");
904
- try {
905
- const { meta: moduleMeta, httpRoutes, procedures } = await parseModuleRuntime(filePath, jitiInstance);
906
- if (moduleMeta) {
907
- meta[moduleName] = moduleMeta;
908
- const fnCount = Object.keys(moduleMeta).length;
909
- totalFunctions += fnCount;
910
- if (debug) console.info(` ✓ ${moduleName}: ${fnCount} functions`);
891
+ globalThis.__BETTER_CONVEX_CODEGEN__ = true;
892
+ try {
893
+ const jitiInstance = createJiti(process.cwd(), {
894
+ interopDefault: true,
895
+ moduleCache: false
896
+ });
897
+ const files = listFilesRecursive(functionsDir).filter((file) => file.endsWith(".ts") && isValidConvexFile(file));
898
+ createdRuntimePlaceholders = ensureGeneratedRuntimePlaceholders(functionsDir, [...new Set([
899
+ ...files.map((file) => file.replace(TS_EXTENSION_RE, "")),
900
+ ...hasRelationsExport ? ["generated/server"] : [],
901
+ ...generateAuth ? [generatedAuthModuleName] : []
902
+ ])]);
903
+ for (const file of files) {
904
+ const filePath = path.join(functionsDir, file);
905
+ const moduleName = file.replace(TS_EXTENSION_RE, "");
906
+ try {
907
+ const { meta: moduleMeta, httpRoutes, procedures } = await parseModuleRuntime(filePath, jitiInstance);
908
+ if (moduleMeta) {
909
+ meta[moduleName] = moduleMeta;
910
+ const fnCount = Object.keys(moduleMeta).length;
911
+ totalFunctions += fnCount;
912
+ if (debug) console.info(` ✓ ${moduleName}: ${fnCount} functions`);
913
+ }
914
+ if (Object.keys(httpRoutes).length > 0 && debug) console.info(` ✓ ${moduleName}: ${Object.keys(httpRoutes).length} HTTP routes`);
915
+ Object.assign(allHttpRoutes, httpRoutes);
916
+ for (const procedure of procedures) procedureEntries.push({
917
+ moduleName,
918
+ exportName: procedure.exportName,
919
+ internal: procedure.internal,
920
+ type: procedure.type,
921
+ kind: "crpc"
922
+ });
923
+ } catch (error) {
924
+ runtimeFilesPreservedFromParseFailures.add(getGeneratedRuntimeOutputFile(functionsDir, moduleName));
925
+ if (debug || file === "http.ts") console.error(` ⚠ Failed to parse ${file}:`, error);
911
926
  }
912
- if (Object.keys(httpRoutes).length > 0 && debug) console.info(` ✓ ${moduleName}: ${Object.keys(httpRoutes).length} HTTP routes`);
913
- Object.assign(allHttpRoutes, httpRoutes);
914
- for (const procedure of procedures) procedureEntries.push({
915
- moduleName,
916
- exportName: procedure.exportName,
917
- internal: procedure.internal,
918
- type: procedure.type,
919
- kind: "crpc"
920
- });
921
- } catch (error) {
922
- runtimeFilesPreservedFromParseFailures.add(getGeneratedRuntimeOutputFile(functionsDir, moduleName));
923
- if (debug || file === "http.ts") console.error(` ⚠ Failed to parse ${file}:`, error);
924
927
  }
928
+ } finally {
929
+ delete globalThis.__BETTER_CONVEX_CODEGEN__;
925
930
  }
926
931
  }
927
932
  if (generateApi) {
@@ -1,5 +1,5 @@
1
1
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BcQFm1oY.js";
2
- import { $ as DatabaseWithQuery, $n as BuildRelationResult, $r as notInArray, $t as defineRelationsPart, A as MigrationRunArgs, An as aggregateIndex, Ar as FieldReference, At as json, B as MigrationMigrateOne, Bn as ConvexUniqueConstraintBuilder, Br as gt, Bt as bigint, C as OrmBeforeResult, Cn as ConvexRankIndexBuilderOn, Cr as ReturningSelection, Ct as ConvexDateBuilderInitial, D as OrmTriggers, Dn as ConvexVectorIndexBuilder, Dr as unsetToken, Dt as ConvexCustomBuilderInitial, E as OrmTriggerContext, En as ConvexSearchIndexConfig, Er as VectorSearchProvider, Et as ConvexCustomBuilder, F as MigrationDirection, Fn as vectorIndex, Fr as between, Ft as ConvexBooleanBuilder, G as MigrationStep, Gn as unique, Gr as isNotNull, Gt as ManyConfig, H as MigrationRunStatus, Hn as ConvexUniqueConstraintConfig, Hr as ilike, Ht as CountBackfillKickoffArgs, I as MigrationDoc, In as ConvexCheckBuilder, Ir as contains, It as ConvexBooleanBuilderInitial, J as buildMigrationPlan, Jn as text, Jr as lt, Jt as RelationsBuilderColumnBase, K as MigrationTableName, Kn as ConvexTextBuilder, Kr as isNull, Kt as OneConfig, L as MigrationDocContext, Ln as ConvexCheckConfig, Lr as endsWith, Lt as boolean, M as MigrationStatusArgs, Mn as rankIndex, Mr as LogicalExpression, Mt as ConvexBytesBuilder, N as MigrationAppliedState, Nn as searchIndex, Nr as UnaryExpression, Nt as ConvexBytesBuilderInitial, O as defineTriggers, On as ConvexVectorIndexBuilderOn, Or as BinaryExpression, Ot as arrayOf, P as MigrationDefinition, Pn as uniqueIndex, Pr as and, Pt as bytes, Q as DatabaseWithMutations, Qn as BuildQueryResult, Qr as notBetween, Qt as defineRelations, R as MigrationDriftIssue, Rn as ConvexForeignKeyBuilder, Rr as eq, Rt as ConvexBigIntBuilder, S as scheduledDeleteFactory, Sn as ConvexRankIndexBuilder, Sr as ReturningResult, St as ConvexDateBuilder, T as OrmTriggerChange, Tn as ConvexSearchIndexBuilderOn, Tr as VectorQueryConfig, Tt as date, U as MigrationSet, Un as check, Ur as inArray, Ut as CountBackfillStatusArgs, V as MigrationPlan, Vn as ConvexUniqueConstraintBuilderOn, Vr as gte, Vt as CountBackfillChunkArgs, W as MigrationStateMap, Wn as foreignKey, Wr as isFieldReference, Wt as ExtractTablesWithRelations, X as defineMigrationSet, Xn as AggregateFieldValue, Xr as ne, Xt as TableRelationalConfig, Y as defineMigration, Yn as AggregateConfig, Yr as lte, Yt as RelationsBuilderColumnConfig, Z as detectMigrationDrift, Zn as AggregateResult, Zr as not, Zt as TablesRelationalConfig, _ as OrmWriterCtx, _i as IsPrimaryKey, _n as rlsRole, _r as OrderByClause, _t as ConvexNumberBuilderInitial, a as TableConfigResult, ai as OrmSchemaPluginTables, an as OrmLifecycleChange, ar as InferInsertModel, at as extractRelationsConfig, b as scheduledMutationBatchFactory, bn as ConvexIndexBuilder, br as PredicateWhereIndexConfig, bt as ConvexIdBuilderInitial, c as OrmNotFoundError, ci as AnyColumn, cn as convexTable, cr as InsertValue, ct as vector, d as GenericOrmCtx, di as ColumnBuilderRuntimeConfig, dn as RlsPolicy, dr as MutationExecutionMode, dt as ConvexTimestampMode, ei as or, en as ConvexDeletionBuilder, er as CountConfig, et as OrmReader, f as OrmApiResult, fi as ColumnBuilderTypeConfig, fn as RlsPolicyConfig, fr as MutationPaginateConfig, ft as timestamp, g as OrmReaderCtx, gi as HasDefault, gn as RlsRoleConfig, gr as MutationRunMode, gt as ConvexNumberBuilder, h as OrmFunctions, hi as DrizzleEntity, hn as RlsRole, hr as MutationReturning, ht as textEnum, i as desc, ii as OrmSchemaPlugin, in as DiscriminatorBuilderConfig, ir as GetColumnData, it as EdgeMetadata, j as MigrationRunChunkArgs, jn as index, jr as FilterExpression, jt as objectOf, k as MigrationCancelArgs, kn as ConvexVectorIndexConfig, kr as ExpressionVisitor, kt as custom, l as CreateOrmOptions, li as ColumnBuilder, ln as deletion, lr as MutationExecuteConfig, lt as ConvexTimestampBuilder, m as OrmClientWithApi, mi as ColumnDataType, mn as rlsPolicy, mr as MutationResult, mt as ConvexTextEnumBuilderInitial, n as defineSchema, ni as Brand, nn as ConvexTable, nr as DBQueryConfig, nt as RlsContext, o as getTableColumns, oi as TableName, on as OrmLifecycleOperation, or as InferModelFromColumns, ot as ConvexVectorBuilder, p as OrmClientBase, pi as ColumnBuilderWithTableName, pn as RlsPolicyToOption, pr as MutationPaginatedResult, pt as ConvexTextEnumBuilder, q as MigrationWriteMode, qn as ConvexTextBuilderInitial, qr as like, qt as RelationsBuilder, r as asc, ri as Columns, rr as FilterOperators, rt as RlsMode, s as getTableConfig, si as SystemFields, sn as TableConfig, sr as InferSelectModel, st as ConvexVectorBuilderInitial, t as WhereClauseResult, ti as startsWith, tn as ConvexDeletionConfig, tr as CountResult, tt as OrmWriter, u as GenericOrm, ui as ColumnBuilderBaseConfig, un as discriminator, ur as MutationExecuteResult, ut as ConvexTimestampBuilderInitial, v as createOrm, vi as IsUnique, vn as ConvexAggregateIndexBuilder, vr as OrderDirection, vt as integer, w as OrmTableTriggers, wn as ConvexSearchIndexBuilder, wr as UpdateSet, wt as ConvexDateMode, x as ScheduledDeleteArgs, xn as ConvexIndexBuilderOn, xr as ReturningAll, xt as id, y as ScheduledMutationBatchArgs, yi as NotNull, yn as ConvexAggregateIndexBuilderOn, yr as PaginatedResult, yt as ConvexIdBuilder, z as MigrationManifestEntry, zn as ConvexForeignKeyConfig, zr as fieldRef, zt as ConvexBigIntBuilderInitial } from "../where-clause-compiler-UavDdMUX.js";
2
+ import { $ as DatabaseWithMutations, $n as BuildQueryResult, $r as notBetween, $t as defineRelations, A as MigrationCancelArgs, An as ConvexVectorIndexConfig, Ar as ExpressionVisitor, At as custom, B as MigrationManifestEntry, Bn as ConvexForeignKeyConfig, Br as fieldRef, Bt as ConvexBigIntBuilderInitial, C as OrmBeforeResult, Cn as ConvexRankIndexBuilder, Cr as ReturningResult, Ct as ConvexDateBuilder, D as OrmTriggers, Dn as ConvexSearchIndexConfig, Dr as VectorSearchProvider, Dt as ConvexCustomBuilder, E as OrmTriggerContext, En as ConvexSearchIndexBuilderOn, Er as VectorQueryConfig, Et as date, F as MigrationDefinition, Fn as uniqueIndex, Fr as and, Ft as bytes, G as MigrationStateMap, Gn as foreignKey, Gr as isFieldReference, Gt as ExtractTablesWithRelations, H as MigrationPlan, Hn as ConvexUniqueConstraintBuilderOn, Hr as gte, Ht as CountBackfillChunkArgs, I as MigrationDirection, In as vectorIndex, Ir as between, It as ConvexBooleanBuilder, J as MigrationWriteMode, Jn as ConvexTextBuilderInitial, Jr as like, Jt as RelationsBuilder, K as MigrationStep, Kn as unique, Kr as isNotNull, Kt as ManyConfig, L as MigrationDoc, Ln as ConvexCheckBuilder, Lr as contains, Lt as ConvexBooleanBuilderInitial, M as MigrationRunChunkArgs, Mn as index, Mr as FilterExpression, Mt as objectOf, N as MigrationStatusArgs, Nn as rankIndex, Nr as LogicalExpression, Nt as ConvexBytesBuilder, O as defineTriggers, On as ConvexVectorIndexBuilder, Or as unsetToken, Ot as ConvexCustomBuilderInitial, P as MigrationAppliedState, Pn as searchIndex, Pr as UnaryExpression, Pt as ConvexBytesBuilderInitial, Q as detectMigrationDrift, Qn as AggregateResult, Qr as not, Qt as TablesRelationalConfig, R as MigrationDocContext, Rn as ConvexCheckConfig, Rr as endsWith, Rt as boolean, S as scheduledDeleteFactory, Sn as ConvexIndexBuilderOn, Sr as ReturningAll, St as id, T as OrmTriggerChange, Tn as ConvexSearchIndexBuilder, Tr as UpdateSet, Tt as ConvexDateMode, U as MigrationRunStatus, Un as ConvexUniqueConstraintConfig, Ur as ilike, Ut as CountBackfillKickoffArgs, V as MigrationMigrateOne, Vn as ConvexUniqueConstraintBuilder, Vr as gt, Vt as bigint, W as MigrationSet, Wn as check, Wr as inArray, Wt as CountBackfillStatusArgs, X as defineMigration, Xn as AggregateConfig, Xr as lte, Xt as RelationsBuilderColumnConfig, Y as buildMigrationPlan, Yn as text, Yr as lt, Yt as RelationsBuilderColumnBase, Z as defineMigrationSet, Zn as AggregateFieldValue, Zr as ne, Zt as TableRelationalConfig, _ as OrmWriterCtx, _i as HasDefault, _n as RlsRoleConfig, _r as MutationRunMode, _t as ConvexNumberBuilder, a as TableConfigResult, ai as OrmSchemaPlugin, an as DiscriminatorBuilderConfig, ar as GetColumnData, at as EdgeMetadata, b as scheduledMutationBatchFactory, bi as NotNull, bn as ConvexAggregateIndexBuilderOn, br as PaginatedResult, bt as ConvexIdBuilder, c as OrmNotFoundError, ci as SystemFields, cn as TableConfig, cr as InferSelectModel, ct as ConvexVectorBuilderInitial, d as GenericOrmCtx, di as ColumnBuilderBaseConfig, dn as discriminator, dr as MutationExecuteResult, dt as ConvexTimestampBuilderInitial, ei as notInArray, en as defineRelationsPart, er as BuildRelationResult, et as DatabaseWithQuery, f as OrmApiResult, fi as ColumnBuilderRuntimeConfig, fn as RlsPolicy, fr as MutationExecutionMode, ft as ConvexTimestampMode, g as OrmReaderCtx, gi as DrizzleEntity, gn as RlsRole, gr as MutationReturning, gt as textEnum, h as OrmFunctions, hi as ColumnDataType, hn as rlsPolicy, hr as MutationResult, ht as ConvexTextEnumBuilderInitial, i as desc, ii as Columns, ir as FilterOperators, it as RlsMode, j as MigrationRunArgs, jn as aggregateIndex, jr as FieldReference, jt as json, kn as ConvexVectorIndexBuilderOn, kr as BinaryExpression, kt as arrayOf, l as CreateOrmOptions, li as AnyColumn, ln as convexTable, lr as InsertValue, lt as vector, m as OrmClientWithApi, mi as ColumnBuilderWithTableName, mn as RlsPolicyToOption, mr as MutationPaginatedResult, mt as ConvexTextEnumBuilder, n as defineSchema, ni as startsWith, nn as ConvexDeletionConfig, nr as CountResult, nt as OrmWriter, o as getTableColumns, oi as OrmSchemaPluginTables, on as OrmLifecycleChange, or as InferInsertModel, ot as extractRelationsConfig, p as OrmClientBase, pi as ColumnBuilderTypeConfig, pn as RlsPolicyConfig, pr as MutationPaginateConfig, pt as timestamp, q as MigrationTableName, qn as ConvexTextBuilder, qr as isNull, qt as OneConfig, r as asc, ri as Brand, rn as ConvexTable, rr as DBQueryConfig, rt as RlsContext, s as getTableConfig, si as TableName, sn as OrmLifecycleOperation, sr as InferModelFromColumns, st as ConvexVectorBuilder, t as WhereClauseResult, ti as or, tn as ConvexDeletionBuilder, tr as CountConfig, tt as OrmReader, u as GenericOrm, ui as ColumnBuilder, un as deletion, ur as MutationExecuteConfig, ut as ConvexTimestampBuilder, v as createOrm, vi as IsPrimaryKey, vn as rlsRole, vr as OrderByClause, vt as ConvexNumberBuilderInitial, w as OrmTableTriggers, wn as ConvexRankIndexBuilderOn, wr as ReturningSelection, wt as ConvexDateBuilderInitial, x as ScheduledDeleteArgs, xn as ConvexIndexBuilder, xr as PredicateWhereIndexConfig, xt as ConvexIdBuilderInitial, y as ScheduledMutationBatchArgs, yi as IsUnique, yn as ConvexAggregateIndexBuilder, yr as OrderDirection, yt as integer, z as MigrationDriftIssue, zn as ConvexForeignKeyBuilder, zr as eq, zt as ConvexBigIntBuilder } from "../where-clause-compiler-DjFwXrQn.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-ji7By8u0.js";
4
4
  import { DefineSchemaOptions, GenericSchema, SchemaDefinition } from "convex/server";
5
5
  export { type AggregateConfig, type AggregateFieldValue, type AggregateResult, type AnyColumn, type BinaryExpression, Brand, type BuildQueryResult, type BuildRelationResult, type ColumnBuilder, type ColumnBuilderBaseConfig, type ColumnBuilderRuntimeConfig, type ColumnBuilderTypeConfig, type ColumnBuilderWithTableName, type ColumnDataType, Columns, type ConvexAggregateIndexBuilder, type ConvexAggregateIndexBuilderOn, type ConvexBigIntBuilder, type ConvexBigIntBuilderInitial, type ConvexBooleanBuilder, type ConvexBooleanBuilderInitial, type ConvexBytesBuilder, type ConvexBytesBuilderInitial, type ConvexCheckBuilder, type ConvexCheckConfig, type ConvexCustomBuilder, type ConvexCustomBuilderInitial, type ConvexDateBuilder, type ConvexDateBuilderInitial, type ConvexDateMode, type ConvexDeletionBuilder, type ConvexDeletionConfig, type ConvexForeignKeyBuilder, type ConvexForeignKeyConfig, type ConvexIdBuilder, type ConvexIdBuilderInitial, type ConvexIndexBuilder, type ConvexIndexBuilderOn, type ConvexNumberBuilder, type ConvexNumberBuilderInitial, type ConvexRankIndexBuilder, type ConvexRankIndexBuilderOn, type ConvexSearchIndexBuilder, type ConvexSearchIndexBuilderOn, type ConvexSearchIndexConfig, type ConvexTable, type ConvexTextBuilder, type ConvexTextBuilderInitial, type ConvexTextEnumBuilder, type ConvexTextEnumBuilderInitial, type ConvexTimestampBuilder, type ConvexTimestampBuilderInitial, type ConvexTimestampMode, type ConvexUniqueConstraintBuilder, type ConvexUniqueConstraintBuilderOn, type ConvexUniqueConstraintConfig, type ConvexVectorBuilder, type ConvexVectorBuilderInitial, type ConvexVectorIndexBuilder, type ConvexVectorIndexBuilderOn, type ConvexVectorIndexConfig, type CountBackfillChunkArgs, type CountBackfillKickoffArgs, type CountBackfillStatusArgs, type CountConfig, type CountResult, type CreateOrmOptions, type DBQueryConfig, type DatabaseWithMutations, type DatabaseWithQuery, type DefineSchemaOptions, type DiscriminatorBuilderConfig, type DocByCtx, type DrizzleEntity, type EdgeMetadata, type ExpressionVisitor, type ExtractTablesWithRelations, type FieldReference, type FilterExpression, type FilterOperators, type GenericOrm, type GenericOrmCtx, type GenericSchema, type GetColumnData, type HasDefault, type InferInsertModel, type InferModelFromColumns, type InferSelectModel, type InsertValue, type IsPrimaryKey, type IsUnique, type LogicalExpression, type LookupByIdResultByCtx, type ManyConfig, 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, type MutationExecuteConfig, type MutationExecuteResult, type MutationExecutionMode, type MutationPaginateConfig, type MutationPaginatedResult, type MutationResult, type MutationReturning, type MutationRunMode, type NotNull, type OneConfig, type OrderByClause, type OrderDirection, type OrmApiResult, type OrmBeforeResult, type OrmClientBase, type OrmClientWithApi, type OrmFunctions, type OrmLifecycleChange, type OrmLifecycleOperation, OrmNotFoundError, type OrmReader, type OrmReaderCtx, type OrmSchemaPlugin, OrmSchemaPluginTables, type OrmTableTriggers, type OrmTriggerChange, type OrmTriggerContext, type OrmTriggers, type OrmWriter, type OrmWriterCtx, type PaginatedResult, type PredicateWhereIndexConfig, type QueryCtxWithOptionalOrmQueryTable, type QueryCtxWithOrmQueryTable, type QueryCtxWithPreferredOrmQueryTable, type RelationsBuilder, type RelationsBuilderColumnBase, type RelationsBuilderColumnConfig, type ReturningAll, type ReturningResult, type ReturningSelection, type RlsContext, type RlsMode, RlsPolicy, type RlsPolicyConfig, type RlsPolicyToOption, RlsRole, type RlsRoleConfig, type ScheduledDeleteArgs, type ScheduledMutationBatchArgs, type SchemaDefinition, type SystemFields, type TableConfig, type TableConfigResult, TableName, type TableRelationalConfig, type TablesRelationalConfig, type UnaryExpression, type UpdateSet, type VectorQueryConfig, type VectorSearchProvider, type WhereClauseResult, aggregateIndex, and, arrayOf, asc, between, bigint, boolean, buildMigrationPlan, bytes, check, contains, convexTable, createOrm, custom, date, defineMigration, defineMigrationSet, defineRelations, defineRelationsPart, defineSchema, defineTriggers, deletion, deprecated, desc, detectMigrationDrift, discriminator, endsWith, eq, extractRelationsConfig, fieldRef, foreignKey, getByIdWithOrmQueryFallback, getTableColumns, getTableConfig, gt, gte, id, ilike, inArray, index, integer, isFieldReference, isNotNull, isNull, json, like, lt, lte, ne, not, notBetween, notInArray, objectOf, or, pretend, pretendRequired, rankIndex, rlsPolicy, rlsRole, scheduledDeleteFactory, scheduledMutationBatchFactory, searchIndex, startsWith, text, textEnum, timestamp, unique, uniqueIndex, unsetToken, vector, vectorIndex };
@@ -1,8 +1,8 @@
1
- import { ii as OrmSchemaPlugin } from "../where-clause-compiler-UavDdMUX.js";
1
+ import "../validators-BcQFm1oY.js";
2
+ import { ai as OrmSchemaPlugin, k as migrationPlugin } from "../where-clause-compiler-DjFwXrQn.js";
3
+ import "../query-context-ji7By8u0.js";
4
+ import "../orm/index.js";
2
5
 
3
- //#region src/orm/migrations/schema.d.ts
4
- declare function migrationPlugin(): OrmSchemaPlugin;
5
- //#endregion
6
6
  //#region src/orm/aggregate-index/schema.d.ts
7
7
  declare function aggregatePlugin(): OrmSchemaPlugin;
8
8
  //#endregion
@@ -1,4 +1,7 @@
1
- import { ii as OrmSchemaPlugin } from "../../where-clause-compiler-UavDdMUX.js";
1
+ import "../../validators-BcQFm1oY.js";
2
+ import { ai as OrmSchemaPlugin } from "../../where-clause-compiler-DjFwXrQn.js";
3
+ import "../../query-context-ji7By8u0.js";
4
+ import "../../orm/index.js";
2
5
  import * as convex_server0 from "convex/server";
3
6
 
4
7
  //#region src/plugins/ratelimit/duration.d.ts
@@ -1184,7 +1184,12 @@ type AuthOptions = {
1184
1184
  };
1185
1185
  type CreateCallerFactoryOptions<TApi> = {
1186
1186
  /** Your Convex API object. */api: TApi; /** Convex site URL (must end in `.convex.site`). */
1187
- convexSiteUrl: string; /** Auth options. Pass to enable authenticated calls with JWT caching. */
1187
+ convexSiteUrl: string;
1188
+ /**
1189
+ * Convex deployment URL (must end in `.convex.cloud`).
1190
+ * Defaults to `convexSiteUrl` with the domain swapped.
1191
+ */
1192
+ convexUrl?: string; /** Auth options. Pass to enable authenticated calls with JWT caching. */
1188
1193
  auth?: AuthOptions; /** Optional wire transformer for request/response payloads (always composed with Date). */
1189
1194
  transformer?: DataTransformerOptions;
1190
1195
  };
@@ -1194,10 +1199,10 @@ type ConvexContext<TApi> = {
1194
1199
  caller: ServerCaller<TApi>;
1195
1200
  };
1196
1201
  declare function createCallerFactory<TApi extends Record<string, unknown>>(opts: CreateCallerFactoryOptions<TApi>): {
1202
+ createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
1197
1203
  createContext: (reqOpts: {
1198
1204
  headers: Headers;
1199
1205
  }) => Promise<ConvexContext<TApi>>;
1200
- createCaller: (ctxFn: () => Promise<ConvexContext<TApi>>) => LazyCaller<TApi>;
1201
1206
  };
1202
1207
  //#endregion
1203
1208
  //#region src/server/context-utils.d.ts
@@ -1,3 +1,4 @@
1
- import { $ as QueryProcedureBuilder, A as GenericCtx, B as ConvexContext, C as CRPC_ERROR_CODE_TO_HTTP, Ct as zodToConvex, D as toCRPCError, E as isCRPCError, F as isRunMutationCtx, G as CallerOpts, H as LazyCaller, I as requireActionCtx, J as createApiLeaf, K as ServerCaller, L as requireMutationCtx, M as isActionCtx, N as isMutationCtx, O as CreateEnvOptions, P as isQueryCtx, Q as ProcedureBuilder, R as requireQueryCtx, S as CRPC_ERROR_CODES_BY_KEY, St as zodOutputToConvexFields, T as getHTTPStatusCodeFromError, U as createLazyCaller, V as createCallerFactory, W as CallerMeta, X as CRPCFunctionTypeHint, Y as ActionProcedureBuilder, Z as MutationProcedureBuilder, _ as WithHttpRouter, _t as zCustomAction, a as ProcedureCaller, at as handleHttpError, b as CRPCError, bt as zid, c as ProcedureFromFunctionReference, ct as ConvexValidatorFromZodOutput, d as createGenericCallerFactory, dt as Zid, et as createMiddlewareFactory, f as createGenericHandlerFactory, ft as ZodFromValidatorBase, g as typedProcedureResolver, gt as withSystemFields, h as defineProcedure, ht as convexToZodFields, i as ProcedureActionCallerFromRegistry, it as extractPathParams, j as RunMutationCtx, k as createEnv, l as ProcedureSchedulableCallerFromRegistry, lt as CustomBuilder, m as createProcedureHandlerFactory, mt as convexToZod, n as GeneratedProcedureRegistry, nt as HttpProcedureBuilder, o as ProcedureCallerFromRegistry, ot as matchPathParams, p as createProcedureCallerFactory, pt as ZodValidatorFromConvex, q as createServerCaller, r as GeneratedProcedureRegistryEntry, rt as createHttpProcedureBuilder, s as ProcedureDefinition, st as ConvexValidatorFromZod, t as CreateProcedureCallerFactoryOptions, tt as initCRPC, u as ProcedureScheduleCallerFromRegistry, ut as ZCustomCtx, v as inferApiInputs, vt as zCustomMutation, w as getCRPCErrorFromUnknown, wt as zodToConvexFields, x as CRPCErrorCode, xt as zodOutputToConvex, y as inferApiOutputs, yt as zCustomQuery, z as requireRunMutationCtx } from "../procedure-caller-DYjpq7rG.js";
1
+ import "../validators-BcQFm1oY.js";
2
+ import { $ as QueryProcedureBuilder, A as GenericCtx, B as ConvexContext, C as CRPC_ERROR_CODE_TO_HTTP, Ct as zodToConvex, D as toCRPCError, E as isCRPCError, F as isRunMutationCtx, G as CallerOpts, H as LazyCaller, I as requireActionCtx, J as createApiLeaf, K as ServerCaller, L as requireMutationCtx, M as isActionCtx, N as isMutationCtx, O as CreateEnvOptions, P as isQueryCtx, Q as ProcedureBuilder, R as requireQueryCtx, S as CRPC_ERROR_CODES_BY_KEY, St as zodOutputToConvexFields, T as getHTTPStatusCodeFromError, U as createLazyCaller, V as createCallerFactory, W as CallerMeta, X as CRPCFunctionTypeHint, Y as ActionProcedureBuilder, Z as MutationProcedureBuilder, _ as WithHttpRouter, _t as zCustomAction, a as ProcedureCaller, at as handleHttpError, b as CRPCError, bt as zid, c as ProcedureFromFunctionReference, ct as ConvexValidatorFromZodOutput, d as createGenericCallerFactory, dt as Zid, et as createMiddlewareFactory, f as createGenericHandlerFactory, ft as ZodFromValidatorBase, g as typedProcedureResolver, gt as withSystemFields, h as defineProcedure, ht as convexToZodFields, i as ProcedureActionCallerFromRegistry, it as extractPathParams, j as RunMutationCtx, k as createEnv, l as ProcedureSchedulableCallerFromRegistry, lt as CustomBuilder, m as createProcedureHandlerFactory, mt as convexToZod, n as GeneratedProcedureRegistry, nt as HttpProcedureBuilder, o as ProcedureCallerFromRegistry, ot as matchPathParams, p as createProcedureCallerFactory, pt as ZodValidatorFromConvex, q as createServerCaller, r as GeneratedProcedureRegistryEntry, rt as createHttpProcedureBuilder, s as ProcedureDefinition, st as ConvexValidatorFromZod, t as CreateProcedureCallerFactoryOptions, tt as initCRPC, u as ProcedureScheduleCallerFromRegistry, ut as ZCustomCtx, v as inferApiInputs, vt as zCustomMutation, w as getCRPCErrorFromUnknown, wt as zodToConvexFields, x as CRPCErrorCode, xt as zodOutputToConvex, y as inferApiOutputs, yt as zCustomQuery, z as requireRunMutationCtx } from "../procedure-caller-kZJx_hmP.js";
2
3
  import { A as GetRawInputFn, B as Simplify, C as HttpProcedure, D as ProcedureMeta, E as InferHttpInput, F as MiddlewareMarker, I as MiddlewareNext, L as MiddlewareResult, M as MergeZodObjects, N as MiddlewareBuilder, O as AnyMiddleware, P as MiddlewareFunction, R as Overwrite, S as HttpMethod, T as HttpRouteDefinition, V as UnsetMarker, _ as extractRouteMap, b as HttpActionHandler, d as CRPCHttpRouter, f as HttpRouterDef, g as createHttpRouterFactory, h as createHttpRouter, j as IntersectIfDefined, k as AnyMiddlewareBuilder, m as HttpRouterWithHono, p as HttpRouterRecord, v as CRPCHonoHandler, w as HttpProcedureBuilderDef, x as HttpHandlerOpts, y as HttpActionConstructor, z as ResolveIfSet } from "../http-types-BK7FuIcR.js";
3
4
  export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, matchPathParams, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
@@ -1,7 +1,7 @@
1
1
  import { l as pick, o as vRequired, t as addFieldsToValidator } from "../validators-D_i3BK7v.js";
2
2
  import { a as isMutationCtx, c as requireActionCtx, d as requireRunMutationCtx, i as isActionCtx, l as requireMutationCtx, n as customCtx, o as isQueryCtx, s as isRunMutationCtx, t as NoOp, u as requireQueryCtx } from "../customFunctions-RnzME_cJ.js";
3
3
  import { i as decodeWire, o as encodeWire, s as getTransformer } from "../transformer-ogg-4d78.js";
4
- import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-CCsm4Dut.js";
4
+ import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-C1uAqm5w.js";
5
5
  import { ConvexError, v } from "convex/values";
6
6
  import { HttpRouter, actionGeneric, getFunctionName, httpActionGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, makeFunctionReference, mutationGeneric, queryGeneric } from "convex/server";
7
7
  import * as z$1 from "zod/v4";
@@ -1985,14 +1985,17 @@ const initCRPC = {
1985
1985
  //#endregion
1986
1986
  //#region src/server/env.ts
1987
1987
  function createEnv(options) {
1988
- const { schema, runtimeEnv = process.env, cache = true, codegenFallback = true } = options;
1988
+ const { schema, runtimeEnv = process.env, cache = true, codegenFallback = false } = options;
1989
1989
  let cached;
1990
1990
  return () => {
1991
1991
  if (cache && cached) return cached;
1992
- const envForParse = codegenFallback && !process.env.NODE_ENV ? {
1992
+ const envForParse = globalThis.__BETTER_CONVEX_CODEGEN__ === true || codegenFallback ? {
1993
1993
  ...Object.fromEntries(Object.entries(schema.shape).map(([key, zodType]) => {
1994
1994
  const result = zodType.safeParse(void 0);
1995
- if (!result.success) return [key, ""];
1995
+ if (!result.success) {
1996
+ if (zodType instanceof z.ZodEnum && Array.isArray(zodType.options) && zodType.options.length > 0) return [key, zodType.options[0]];
1997
+ return [key, ""];
1998
+ }
1996
1999
  return [key, typeof result.data === "string" ? result.data : void 0];
1997
2000
  })),
1998
2001
  ...runtimeEnv
package/dist/watcher.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as getConvexConfig, t as generateMeta } from "./codegen-BS36cYTH.mjs";
2
+ import { n as getConvexConfig, t as generateMeta } from "./codegen-CMQIKrqh.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
@@ -3420,6 +3420,9 @@ type MigrationCancelArgs = {
3420
3420
  runId?: string;
3421
3421
  };
3422
3422
  //#endregion
3423
+ //#region src/orm/migrations/schema.d.ts
3424
+ declare function migrationPlugin(): OrmSchemaPlugin;
3425
+ //#endregion
3423
3426
  //#region src/orm/triggers.d.ts
3424
3427
  type MaybePromise<T> = T | Promise<T>;
3425
3428
  type AnyRecord = Record<string, unknown>;
@@ -3692,4 +3695,4 @@ interface IndexLike {
3692
3695
  indexName: string;
3693
3696
  }
3694
3697
  //#endregion
3695
- export { DatabaseWithQuery as $, BuildRelationResult as $n, notInArray as $r, defineRelationsPart as $t, MigrationRunArgs as A, aggregateIndex as An, FieldReference as Ar, json as At, MigrationMigrateOne as B, ConvexUniqueConstraintBuilder as Bn, gt as Br, bigint as Bt, OrmBeforeResult as C, ConvexRankIndexBuilderOn as Cn, ReturningSelection as Cr, ConvexDateBuilderInitial as Ct, OrmTriggers as D, ConvexVectorIndexBuilder as Dn, unsetToken as Dr, ConvexCustomBuilderInitial as Dt, OrmTriggerContext as E, ConvexSearchIndexConfig as En, VectorSearchProvider as Er, ConvexCustomBuilder as Et, MigrationDirection as F, vectorIndex as Fn, between as Fr, ConvexBooleanBuilder as Ft, MigrationStep as G, unique as Gn, isNotNull as Gr, ManyConfig as Gt, MigrationRunStatus as H, ConvexUniqueConstraintConfig as Hn, ilike as Hr, CountBackfillKickoffArgs as Ht, MigrationDoc as I, ConvexCheckBuilder as In, contains as Ir, ConvexBooleanBuilderInitial as It, buildMigrationPlan as J, text as Jn, lt as Jr, RelationsBuilderColumnBase as Jt, MigrationTableName as K, ConvexTextBuilder as Kn, isNull as Kr, OneConfig as Kt, MigrationDocContext as L, ConvexCheckConfig as Ln, endsWith as Lr, boolean as Lt, MigrationStatusArgs as M, rankIndex as Mn, LogicalExpression as Mr, ConvexBytesBuilder as Mt, MigrationAppliedState as N, searchIndex as Nn, UnaryExpression as Nr, ConvexBytesBuilderInitial as Nt, defineTriggers as O, ConvexVectorIndexBuilderOn as On, BinaryExpression as Or, arrayOf as Ot, MigrationDefinition as P, uniqueIndex as Pn, and as Pr, bytes as Pt, DatabaseWithMutations as Q, BuildQueryResult as Qn, notBetween as Qr, defineRelations as Qt, MigrationDriftIssue as R, ConvexForeignKeyBuilder as Rn, eq as Rr, ConvexBigIntBuilder as Rt, scheduledDeleteFactory as S, ConvexRankIndexBuilder as Sn, ReturningResult as Sr, ConvexDateBuilder as St, OrmTriggerChange as T, ConvexSearchIndexBuilderOn as Tn, VectorQueryConfig as Tr, date as Tt, MigrationSet as U, check as Un, inArray as Ur, CountBackfillStatusArgs as Ut, MigrationPlan as V, ConvexUniqueConstraintBuilderOn as Vn, gte as Vr, CountBackfillChunkArgs as Vt, MigrationStateMap as W, foreignKey as Wn, isFieldReference as Wr, ExtractTablesWithRelations as Wt, defineMigrationSet as X, AggregateFieldValue as Xn, ne as Xr, TableRelationalConfig as Xt, defineMigration as Y, AggregateConfig as Yn, lte as Yr, RelationsBuilderColumnConfig as Yt, detectMigrationDrift as Z, AggregateResult as Zn, not as Zr, TablesRelationalConfig as Zt, OrmWriterCtx as _, IsPrimaryKey as _i, rlsRole as _n, OrderByClause as _r, ConvexNumberBuilderInitial as _t, TableConfigResult as a, OrmSchemaPluginTables as ai, OrmLifecycleChange as an, InferInsertModel as ar, extractRelationsConfig as at, scheduledMutationBatchFactory as b, ConvexIndexBuilder as bn, PredicateWhereIndexConfig as br, ConvexIdBuilderInitial as bt, OrmNotFoundError as c, AnyColumn as ci, convexTable as cn, InsertValue as cr, vector as ct, GenericOrmCtx as d, ColumnBuilderRuntimeConfig as di, RlsPolicy as dn, MutationExecutionMode as dr, ConvexTimestampMode as dt, or as ei, ConvexDeletionBuilder as en, CountConfig as er, OrmReader as et, OrmApiResult as f, ColumnBuilderTypeConfig as fi, RlsPolicyConfig as fn, MutationPaginateConfig as fr, timestamp as ft, OrmReaderCtx as g, HasDefault as gi, RlsRoleConfig as gn, MutationRunMode as gr, ConvexNumberBuilder as gt, OrmFunctions as h, DrizzleEntity as hi, RlsRole as hn, MutationReturning as hr, textEnum as ht, desc as i, OrmSchemaPlugin as ii, DiscriminatorBuilderConfig as in, GetColumnData as ir, EdgeMetadata as it, MigrationRunChunkArgs as j, index as jn, FilterExpression$1 as jr, objectOf as jt, MigrationCancelArgs as k, ConvexVectorIndexConfig as kn, ExpressionVisitor as kr, custom as kt, CreateOrmOptions as l, ColumnBuilder as li, deletion as ln, MutationExecuteConfig as lr, ConvexTimestampBuilder as lt, OrmClientWithApi as m, ColumnDataType as mi, rlsPolicy as mn, MutationResult as mr, ConvexTextEnumBuilderInitial as mt, defineSchema$1 as n, Brand as ni, ConvexTable as nn, DBQueryConfig as nr, RlsContext as nt, getTableColumns as o, TableName as oi, OrmLifecycleOperation as on, InferModelFromColumns as or, ConvexVectorBuilder as ot, OrmClientBase as p, ColumnBuilderWithTableName as pi, RlsPolicyToOption as pn, MutationPaginatedResult as pr, ConvexTextEnumBuilder as pt, MigrationWriteMode as q, ConvexTextBuilderInitial as qn, like as qr, RelationsBuilder as qt, asc as r, Columns as ri, ConvexTableWithColumns as rn, FilterOperators as rr, RlsMode as rt, getTableConfig as s, SystemFields as si, TableConfig as sn, InferSelectModel as sr, ConvexVectorBuilderInitial as st, WhereClauseResult as t, startsWith as ti, ConvexDeletionConfig as tn, CountResult as tr, OrmWriter as tt, GenericOrm as u, ColumnBuilderBaseConfig as ui, discriminator as un, MutationExecuteResult as ur, ConvexTimestampBuilderInitial as ut, createOrm as v, IsUnique as vi, ConvexAggregateIndexBuilder as vn, OrderDirection as vr, integer as vt, OrmTableTriggers as w, ConvexSearchIndexBuilder as wn, UpdateSet as wr, ConvexDateMode as wt, ScheduledDeleteArgs as x, ConvexIndexBuilderOn as xn, ReturningAll as xr, id as xt, ScheduledMutationBatchArgs as y, NotNull as yi, ConvexAggregateIndexBuilderOn as yn, PaginatedResult as yr, ConvexIdBuilder as yt, MigrationManifestEntry as z, ConvexForeignKeyConfig as zn, fieldRef as zr, ConvexBigIntBuilderInitial as zt };
3698
+ export { DatabaseWithMutations as $, BuildQueryResult as $n, notBetween as $r, defineRelations as $t, MigrationCancelArgs as A, ConvexVectorIndexConfig as An, ExpressionVisitor as Ar, custom as At, MigrationManifestEntry as B, ConvexForeignKeyConfig as Bn, fieldRef as Br, ConvexBigIntBuilderInitial as Bt, OrmBeforeResult as C, ConvexRankIndexBuilder as Cn, ReturningResult as Cr, ConvexDateBuilder as Ct, OrmTriggers as D, ConvexSearchIndexConfig as Dn, VectorSearchProvider as Dr, ConvexCustomBuilder as Dt, OrmTriggerContext as E, ConvexSearchIndexBuilderOn as En, VectorQueryConfig as Er, date as Et, MigrationDefinition as F, uniqueIndex as Fn, and as Fr, bytes as Ft, MigrationStateMap as G, foreignKey as Gn, isFieldReference as Gr, ExtractTablesWithRelations as Gt, MigrationPlan as H, ConvexUniqueConstraintBuilderOn as Hn, gte as Hr, CountBackfillChunkArgs as Ht, MigrationDirection as I, vectorIndex as In, between as Ir, ConvexBooleanBuilder as It, MigrationWriteMode as J, ConvexTextBuilderInitial as Jn, like as Jr, RelationsBuilder as Jt, MigrationStep as K, unique as Kn, isNotNull as Kr, ManyConfig as Kt, MigrationDoc as L, ConvexCheckBuilder as Ln, contains as Lr, ConvexBooleanBuilderInitial as Lt, MigrationRunChunkArgs as M, index as Mn, FilterExpression$1 as Mr, objectOf as Mt, MigrationStatusArgs as N, rankIndex as Nn, LogicalExpression as Nr, ConvexBytesBuilder as Nt, defineTriggers as O, ConvexVectorIndexBuilder as On, unsetToken as Or, ConvexCustomBuilderInitial as Ot, MigrationAppliedState as P, searchIndex as Pn, UnaryExpression as Pr, ConvexBytesBuilderInitial as Pt, detectMigrationDrift as Q, AggregateResult as Qn, not as Qr, TablesRelationalConfig as Qt, MigrationDocContext as R, ConvexCheckConfig as Rn, endsWith as Rr, boolean as Rt, scheduledDeleteFactory as S, ConvexIndexBuilderOn as Sn, ReturningAll as Sr, id as St, OrmTriggerChange as T, ConvexSearchIndexBuilder as Tn, UpdateSet as Tr, ConvexDateMode as Tt, MigrationRunStatus as U, ConvexUniqueConstraintConfig as Un, ilike as Ur, CountBackfillKickoffArgs as Ut, MigrationMigrateOne as V, ConvexUniqueConstraintBuilder as Vn, gt as Vr, bigint as Vt, MigrationSet as W, check as Wn, inArray as Wr, CountBackfillStatusArgs as Wt, defineMigration as X, AggregateConfig as Xn, lte as Xr, RelationsBuilderColumnConfig as Xt, buildMigrationPlan as Y, text as Yn, lt as Yr, RelationsBuilderColumnBase as Yt, defineMigrationSet as Z, AggregateFieldValue as Zn, ne as Zr, TableRelationalConfig as Zt, OrmWriterCtx as _, HasDefault as _i, RlsRoleConfig as _n, MutationRunMode as _r, ConvexNumberBuilder as _t, TableConfigResult as a, OrmSchemaPlugin as ai, DiscriminatorBuilderConfig as an, GetColumnData as ar, EdgeMetadata as at, scheduledMutationBatchFactory as b, NotNull as bi, ConvexAggregateIndexBuilderOn as bn, PaginatedResult as br, ConvexIdBuilder as bt, OrmNotFoundError as c, SystemFields as ci, TableConfig as cn, InferSelectModel as cr, ConvexVectorBuilderInitial as ct, GenericOrmCtx as d, ColumnBuilderBaseConfig as di, discriminator as dn, MutationExecuteResult as dr, ConvexTimestampBuilderInitial as dt, notInArray as ei, defineRelationsPart as en, BuildRelationResult as er, DatabaseWithQuery as et, OrmApiResult as f, ColumnBuilderRuntimeConfig as fi, RlsPolicy as fn, MutationExecutionMode as fr, ConvexTimestampMode as ft, OrmReaderCtx as g, DrizzleEntity as gi, RlsRole as gn, MutationReturning as gr, textEnum as gt, OrmFunctions as h, ColumnDataType as hi, rlsPolicy as hn, MutationResult as hr, ConvexTextEnumBuilderInitial as ht, desc as i, Columns as ii, ConvexTableWithColumns as in, FilterOperators as ir, RlsMode as it, MigrationRunArgs as j, aggregateIndex as jn, FieldReference as jr, json as jt, migrationPlugin as k, ConvexVectorIndexBuilderOn as kn, BinaryExpression as kr, arrayOf as kt, CreateOrmOptions as l, AnyColumn as li, convexTable as ln, InsertValue as lr, vector as lt, OrmClientWithApi as m, ColumnBuilderWithTableName as mi, RlsPolicyToOption as mn, MutationPaginatedResult as mr, ConvexTextEnumBuilder as mt, defineSchema$1 as n, startsWith as ni, ConvexDeletionConfig as nn, CountResult as nr, OrmWriter as nt, getTableColumns as o, OrmSchemaPluginTables as oi, OrmLifecycleChange as on, InferInsertModel as or, extractRelationsConfig as ot, OrmClientBase as p, ColumnBuilderTypeConfig as pi, RlsPolicyConfig as pn, MutationPaginateConfig as pr, timestamp as pt, MigrationTableName as q, ConvexTextBuilder as qn, isNull as qr, OneConfig as qt, asc as r, Brand as ri, ConvexTable as rn, DBQueryConfig as rr, RlsContext as rt, getTableConfig as s, TableName as si, OrmLifecycleOperation as sn, InferModelFromColumns as sr, ConvexVectorBuilder as st, WhereClauseResult as t, or as ti, ConvexDeletionBuilder as tn, CountConfig as tr, OrmReader as tt, GenericOrm as u, ColumnBuilder as ui, deletion as un, MutationExecuteConfig as ur, ConvexTimestampBuilder as ut, createOrm as v, IsPrimaryKey as vi, rlsRole as vn, OrderByClause as vr, ConvexNumberBuilderInitial as vt, OrmTableTriggers as w, ConvexRankIndexBuilderOn as wn, ReturningSelection as wr, ConvexDateBuilderInitial as wt, ScheduledDeleteArgs as x, ConvexIndexBuilder as xn, PredicateWhereIndexConfig as xr, ConvexIdBuilderInitial as xt, ScheduledMutationBatchArgs as y, IsUnique as yi, ConvexAggregateIndexBuilder as yn, OrderDirection as yr, integer as yt, MigrationDriftIssue as z, ConvexForeignKeyBuilder as zn, eq as zr, ConvexBigIntBuilder as zt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-convex",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Better Convex - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",