better-convex 0.6.2 → 0.6.4
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.
- package/dist/auth/index.d.ts +47 -47
- package/dist/auth/index.js +1 -1
- package/dist/auth-nextjs/index.d.ts +1 -0
- package/dist/orm/index.d.ts +33 -7
- package/dist/orm/index.js +1 -1
- package/dist/{orm-Banm-XXb.js → orm-BKc-pwj_.js} +59 -50
- package/package.json +1 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as GenericCtx } from "../context-utils-DSuX99Da.js";
|
|
2
2
|
import { convex } from "@convex-dev/better-auth/plugins";
|
|
3
|
-
import * as
|
|
3
|
+
import * as better_auth_adapters0 from "better-auth/adapters";
|
|
4
4
|
import { DBAdapterDebugLogOption } from "better-auth/adapters";
|
|
5
5
|
import { BetterAuthDBSchema } from "better-auth/db";
|
|
6
|
-
import * as
|
|
6
|
+
import * as convex_server0 from "convex/server";
|
|
7
7
|
import { DocumentByName, FunctionReference, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, HttpRouter, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel, internalMutationGeneric } from "convex/server";
|
|
8
8
|
import * as convex_values0 from "convex/values";
|
|
9
9
|
import { Infer } from "convex/values";
|
|
@@ -45,30 +45,30 @@ declare const createClient: <DataModel extends GenericDataModel, Schema extends
|
|
|
45
45
|
}) => {
|
|
46
46
|
authFunctions: AuthFunctions;
|
|
47
47
|
triggers: Triggers<DataModel, Schema, TriggerCtx> | undefined;
|
|
48
|
-
adapter: (ctx: GenericCtx<DataModel>, getAuthOptions: (ctx: any) => BetterAuthOptions) =>
|
|
48
|
+
adapter: (ctx: GenericCtx<DataModel>, getAuthOptions: (ctx: any) => BetterAuthOptions) => better_auth_adapters0.AdapterFactory;
|
|
49
49
|
triggersApi: () => {
|
|
50
|
-
beforeCreate:
|
|
50
|
+
beforeCreate: convex_server0.RegisteredMutation<"internal", {
|
|
51
51
|
data: any;
|
|
52
52
|
model: string;
|
|
53
53
|
}, Promise<any>>;
|
|
54
|
-
beforeDelete:
|
|
54
|
+
beforeDelete: convex_server0.RegisteredMutation<"internal", {
|
|
55
55
|
model: string;
|
|
56
56
|
doc: any;
|
|
57
57
|
}, Promise<any>>;
|
|
58
|
-
beforeUpdate:
|
|
58
|
+
beforeUpdate: convex_server0.RegisteredMutation<"internal", {
|
|
59
59
|
update: any;
|
|
60
60
|
model: string;
|
|
61
61
|
doc: any;
|
|
62
62
|
}, Promise<any>>;
|
|
63
|
-
onCreate:
|
|
63
|
+
onCreate: convex_server0.RegisteredMutation<"internal", {
|
|
64
64
|
model: string;
|
|
65
65
|
doc: any;
|
|
66
66
|
}, Promise<void>>;
|
|
67
|
-
onDelete:
|
|
67
|
+
onDelete: convex_server0.RegisteredMutation<"internal", {
|
|
68
68
|
model: string;
|
|
69
69
|
doc: any;
|
|
70
70
|
}, Promise<void>>;
|
|
71
|
-
onUpdate:
|
|
71
|
+
onUpdate: convex_server0.RegisteredMutation<"internal", {
|
|
72
72
|
model: string;
|
|
73
73
|
newDoc: any;
|
|
74
74
|
oldDoc: any;
|
|
@@ -150,7 +150,7 @@ declare const httpAdapter: <DataModel extends GenericDataModel, Schema extends S
|
|
|
150
150
|
debugLogs?: DBAdapterDebugLogOption;
|
|
151
151
|
schema?: Schema;
|
|
152
152
|
triggers?: Triggers<DataModel, Schema>;
|
|
153
|
-
}) =>
|
|
153
|
+
}) => better_auth_adapters0.AdapterFactory;
|
|
154
154
|
declare const dbAdapter: <DataModel extends GenericDataModel, Schema extends SchemaDefinition<any, any>>(ctx: GenericCtx<DataModel>, getAuthOptions: (ctx: any) => BetterAuthOptions, {
|
|
155
155
|
authFunctions,
|
|
156
156
|
debugLogs,
|
|
@@ -161,7 +161,7 @@ declare const dbAdapter: <DataModel extends GenericDataModel, Schema extends Sch
|
|
|
161
161
|
schema: Schema;
|
|
162
162
|
debugLogs?: DBAdapterDebugLogOption;
|
|
163
163
|
triggers?: Triggers<DataModel, Schema>;
|
|
164
|
-
}) =>
|
|
164
|
+
}) => better_auth_adapters0.AdapterFactory;
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/auth/adapter-utils.d.ts
|
|
167
167
|
type AdapterPaginationOptions = PaginationOptions & {
|
|
@@ -171,14 +171,14 @@ type AdapterPaginationOptions = PaginationOptions & {
|
|
|
171
171
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
172
172
|
connector?: "AND" | "OR" | undefined;
|
|
173
173
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
174
|
-
field: string;
|
|
175
174
|
value: string | number | boolean | string[] | number[] | null;
|
|
175
|
+
field: string;
|
|
176
176
|
}, {
|
|
177
177
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
178
178
|
field: convex_values0.VString<string, "required">;
|
|
179
179
|
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>;
|
|
180
180
|
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>;
|
|
181
|
-
}, "required", "
|
|
181
|
+
}, "required", "value" | "connector" | "field" | "operator">;
|
|
182
182
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
183
183
|
limit?: number | undefined;
|
|
184
184
|
select?: string[] | undefined;
|
|
@@ -190,8 +190,8 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
190
190
|
where?: {
|
|
191
191
|
connector?: "AND" | "OR" | undefined;
|
|
192
192
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
193
|
-
field: string;
|
|
194
193
|
value: string | number | boolean | string[] | number[] | null;
|
|
194
|
+
field: string;
|
|
195
195
|
}[] | undefined;
|
|
196
196
|
model: string;
|
|
197
197
|
}, {
|
|
@@ -209,19 +209,19 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
209
209
|
where: convex_values0.VArray<{
|
|
210
210
|
connector?: "AND" | "OR" | undefined;
|
|
211
211
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
212
|
-
field: string;
|
|
213
212
|
value: string | number | boolean | string[] | number[] | null;
|
|
213
|
+
field: string;
|
|
214
214
|
}[] | undefined, convex_values0.VObject<{
|
|
215
215
|
connector?: "AND" | "OR" | undefined;
|
|
216
216
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
217
|
-
field: string;
|
|
218
217
|
value: string | number | boolean | string[] | number[] | null;
|
|
218
|
+
field: string;
|
|
219
219
|
}, {
|
|
220
220
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
221
221
|
field: convex_values0.VString<string, "required">;
|
|
222
222
|
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>;
|
|
223
223
|
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>;
|
|
224
|
-
}, "required", "
|
|
224
|
+
}, "required", "value" | "connector" | "field" | "operator">, "optional">;
|
|
225
225
|
}, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.field" | "sortBy.direction">;
|
|
226
226
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
227
227
|
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>;
|
|
@@ -250,7 +250,7 @@ declare const findOneHandler: (ctx: any, args: {
|
|
|
250
250
|
model: string;
|
|
251
251
|
select?: string[];
|
|
252
252
|
where?: any[];
|
|
253
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
253
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.GenericDocument | null>;
|
|
254
254
|
declare const findManyHandler: (ctx: any, args: {
|
|
255
255
|
model: string;
|
|
256
256
|
paginationOpts: any;
|
|
@@ -261,7 +261,7 @@ declare const findManyHandler: (ctx: any, args: {
|
|
|
261
261
|
field: string;
|
|
262
262
|
};
|
|
263
263
|
where?: any[];
|
|
264
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
264
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>;
|
|
265
265
|
declare const updateOneHandler: (ctx: any, args: {
|
|
266
266
|
input: {
|
|
267
267
|
model: string;
|
|
@@ -284,8 +284,8 @@ declare const updateManyHandler: (ctx: any, args: {
|
|
|
284
284
|
count: number;
|
|
285
285
|
ids: any[];
|
|
286
286
|
isDone: boolean;
|
|
287
|
-
continueCursor:
|
|
288
|
-
splitCursor?:
|
|
287
|
+
continueCursor: convex_server0.Cursor;
|
|
288
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
289
289
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
290
290
|
}>;
|
|
291
291
|
declare const deleteOneHandler: (ctx: any, args: {
|
|
@@ -296,7 +296,7 @@ declare const deleteOneHandler: (ctx: any, args: {
|
|
|
296
296
|
beforeDeleteHandle?: string;
|
|
297
297
|
skipBeforeHooks?: boolean;
|
|
298
298
|
onDeleteHandle?: string;
|
|
299
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
299
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server0.GenericDocument | undefined>;
|
|
300
300
|
declare const deleteManyHandler: (ctx: any, args: {
|
|
301
301
|
input: {
|
|
302
302
|
model: string;
|
|
@@ -310,8 +310,8 @@ declare const deleteManyHandler: (ctx: any, args: {
|
|
|
310
310
|
count: number;
|
|
311
311
|
ids: any[];
|
|
312
312
|
isDone: boolean;
|
|
313
|
-
continueCursor:
|
|
314
|
-
splitCursor?:
|
|
313
|
+
continueCursor: convex_server0.Cursor;
|
|
314
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
315
315
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
316
316
|
}>;
|
|
317
317
|
declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Schema, getAuth: GetAuth, options?: {
|
|
@@ -319,7 +319,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
319
319
|
context?: (ctx: any) => any | Promise<any>; /** Skip input validation for smaller generated types. Since these are internal functions, validation is optional. */
|
|
320
320
|
skipValidation?: boolean;
|
|
321
321
|
}) => {
|
|
322
|
-
create:
|
|
322
|
+
create: convex_server0.RegisteredMutation<"internal", {
|
|
323
323
|
select?: string[] | undefined;
|
|
324
324
|
beforeCreateHandle?: string | undefined;
|
|
325
325
|
onCreateHandle?: string | undefined;
|
|
@@ -335,7 +335,7 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
335
335
|
model: string;
|
|
336
336
|
};
|
|
337
337
|
}, Promise<any>>;
|
|
338
|
-
deleteMany:
|
|
338
|
+
deleteMany: convex_server0.RegisteredMutation<"internal", {
|
|
339
339
|
beforeDeleteHandle?: string | undefined;
|
|
340
340
|
onDeleteHandle?: string | undefined;
|
|
341
341
|
paginationOpts: {
|
|
@@ -353,8 +353,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
353
353
|
where?: {
|
|
354
354
|
connector?: "AND" | "OR" | undefined;
|
|
355
355
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
356
|
-
field: string;
|
|
357
356
|
value: string | number | boolean | string[] | number[] | null;
|
|
357
|
+
field: string;
|
|
358
358
|
}[] | undefined;
|
|
359
359
|
model: string;
|
|
360
360
|
};
|
|
@@ -362,11 +362,11 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
362
362
|
count: number;
|
|
363
363
|
ids: any[];
|
|
364
364
|
isDone: boolean;
|
|
365
|
-
continueCursor:
|
|
366
|
-
splitCursor?:
|
|
365
|
+
continueCursor: convex_server0.Cursor;
|
|
366
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
367
367
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
368
368
|
}>>;
|
|
369
|
-
deleteOne:
|
|
369
|
+
deleteOne: convex_server0.RegisteredMutation<"internal", {
|
|
370
370
|
beforeDeleteHandle?: string | undefined;
|
|
371
371
|
onDeleteHandle?: string | undefined;
|
|
372
372
|
input: {
|
|
@@ -376,15 +376,15 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
376
376
|
where?: {
|
|
377
377
|
connector?: "AND" | "OR" | undefined;
|
|
378
378
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
379
|
-
field: string;
|
|
380
379
|
value: string | number | boolean | string[] | number[] | null;
|
|
380
|
+
field: string;
|
|
381
381
|
}[] | undefined;
|
|
382
382
|
model: string;
|
|
383
383
|
};
|
|
384
|
-
}, Promise<
|
|
385
|
-
findMany:
|
|
386
|
-
limit?: number | undefined;
|
|
384
|
+
}, Promise<convex_server0.GenericDocument | undefined>>;
|
|
385
|
+
findMany: convex_server0.RegisteredQuery<"internal", {
|
|
387
386
|
join?: any;
|
|
387
|
+
limit?: number | undefined;
|
|
388
388
|
offset?: number | undefined;
|
|
389
389
|
sortBy?: {
|
|
390
390
|
field: string;
|
|
@@ -393,8 +393,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
393
393
|
where?: {
|
|
394
394
|
connector?: "AND" | "OR" | undefined;
|
|
395
395
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
396
|
-
field: string;
|
|
397
396
|
value: string | number | boolean | string[] | number[] | null;
|
|
397
|
+
field: string;
|
|
398
398
|
}[] | undefined;
|
|
399
399
|
paginationOpts: {
|
|
400
400
|
id?: number;
|
|
@@ -405,19 +405,19 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
405
405
|
cursor: string | null;
|
|
406
406
|
};
|
|
407
407
|
model: string;
|
|
408
|
-
}, Promise<
|
|
409
|
-
findOne:
|
|
408
|
+
}, Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>>;
|
|
409
|
+
findOne: convex_server0.RegisteredQuery<"internal", {
|
|
410
410
|
join?: any;
|
|
411
411
|
select?: string[] | undefined;
|
|
412
412
|
where?: {
|
|
413
413
|
connector?: "AND" | "OR" | undefined;
|
|
414
414
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
415
|
-
field: string;
|
|
416
415
|
value: string | number | boolean | string[] | number[] | null;
|
|
416
|
+
field: string;
|
|
417
417
|
}[] | undefined;
|
|
418
418
|
model: string;
|
|
419
|
-
}, Promise<
|
|
420
|
-
updateMany:
|
|
419
|
+
}, Promise<convex_server0.GenericDocument | null>>;
|
|
420
|
+
updateMany: convex_server0.RegisteredMutation<"internal", {
|
|
421
421
|
beforeUpdateHandle?: string | undefined;
|
|
422
422
|
onUpdateHandle?: string | undefined;
|
|
423
423
|
paginationOpts: {
|
|
@@ -436,8 +436,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
436
436
|
where?: {
|
|
437
437
|
connector?: "AND" | "OR" | undefined;
|
|
438
438
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
439
|
-
field: string;
|
|
440
439
|
value: string | number | boolean | string[] | number[] | null;
|
|
440
|
+
field: string;
|
|
441
441
|
}[] | undefined;
|
|
442
442
|
update: {
|
|
443
443
|
[x: string]: unknown;
|
|
@@ -450,11 +450,11 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
450
450
|
count: number;
|
|
451
451
|
ids: any[];
|
|
452
452
|
isDone: boolean;
|
|
453
|
-
continueCursor:
|
|
454
|
-
splitCursor?:
|
|
453
|
+
continueCursor: convex_server0.Cursor;
|
|
454
|
+
splitCursor?: convex_server0.Cursor | null;
|
|
455
455
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
456
456
|
}>>;
|
|
457
|
-
updateOne:
|
|
457
|
+
updateOne: convex_server0.RegisteredMutation<"internal", {
|
|
458
458
|
beforeUpdateHandle?: string | undefined;
|
|
459
459
|
onUpdateHandle?: string | undefined;
|
|
460
460
|
input: {
|
|
@@ -465,8 +465,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
465
465
|
where?: {
|
|
466
466
|
connector?: "AND" | "OR" | undefined;
|
|
467
467
|
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
468
|
-
field: string;
|
|
469
468
|
value: string | number | boolean | string[] | number[] | null;
|
|
469
|
+
field: string;
|
|
470
470
|
}[] | undefined;
|
|
471
471
|
update: {
|
|
472
472
|
[x: string]: unknown;
|
|
@@ -476,8 +476,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>>(schema: Sch
|
|
|
476
476
|
model: string;
|
|
477
477
|
};
|
|
478
478
|
}, Promise<any>>;
|
|
479
|
-
getLatestJwks:
|
|
480
|
-
rotateKeys:
|
|
479
|
+
getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<any>>;
|
|
480
|
+
rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<any>>;
|
|
481
481
|
};
|
|
482
482
|
//#endregion
|
|
483
483
|
//#region src/auth/helpers.d.ts
|
package/dist/auth/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as partial, h as asyncMap, l as isQueryCtx, n as customCtx, r as customMutation, u as isRunMutationCtx } from "../customFunctions-C1okqCzL.js";
|
|
2
|
-
import { C as stream, D as unsetToken, L as eq, S as mergedStream } from "../orm-
|
|
2
|
+
import { C as stream, D as unsetToken, L as eq, S as mergedStream } from "../orm-BKc-pwj_.js";
|
|
3
3
|
import { convex } from "@convex-dev/better-auth/plugins";
|
|
4
4
|
import { createAdapterFactory } from "better-auth/adapters";
|
|
5
5
|
import { getAuthTables } from "better-auth/db";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { g as LazyCaller, m as ConvexContext, v as CallerMeta } from "../index-BQkhP2ny.js";
|
|
2
2
|
import "../http-types-BRLY10NX.js";
|
|
3
|
+
import "../context-utils-DSuX99Da.js";
|
|
3
4
|
import { GetTokenOptions } from "@convex-dev/better-auth/utils";
|
|
4
5
|
|
|
5
6
|
//#region src/auth-nextjs/index.d.ts
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -530,6 +530,28 @@ declare class ConvexSystemIdBuilder<_TTableName extends string> extends ColumnBu
|
|
|
530
530
|
*/
|
|
531
531
|
get convexValidator(): convex_values63.VString<string, "required">;
|
|
532
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* System creation time field builder (_creationTime)
|
|
535
|
+
* Always present, always non-null, always a number (milliseconds)
|
|
536
|
+
*/
|
|
537
|
+
type ConvexSystemCreationTimeConfig = ColumnBuilderBaseConfig<'number', 'ConvexSystemCreationTime'> & {
|
|
538
|
+
data: number;
|
|
539
|
+
driverParam: number;
|
|
540
|
+
enumValues: undefined;
|
|
541
|
+
};
|
|
542
|
+
declare class ConvexSystemCreationTimeBuilder extends ColumnBuilder<ConvexSystemCreationTimeConfig, {}, {
|
|
543
|
+
notNull: true;
|
|
544
|
+
}> {
|
|
545
|
+
static readonly [entityKind]: string;
|
|
546
|
+
readonly [entityKind]: string;
|
|
547
|
+
constructor();
|
|
548
|
+
build(): convex_values63.VFloat64<number, "required">;
|
|
549
|
+
/**
|
|
550
|
+
* Convex validator - runtime access
|
|
551
|
+
* System fields use v.number() for _creationTime
|
|
552
|
+
*/
|
|
553
|
+
get convexValidator(): convex_values63.VFloat64<number, "required">;
|
|
554
|
+
}
|
|
533
555
|
type ConvexSystemCreatedAtConfig = ColumnBuilderBaseConfig<'number', 'ConvexSystemCreatedAt'> & {
|
|
534
556
|
data: number;
|
|
535
557
|
driverParam: number;
|
|
@@ -551,9 +573,13 @@ declare class ConvexSystemCreatedAtBuilder extends ColumnBuilder<ConvexSystemCre
|
|
|
551
573
|
type SystemFields<TName extends string> = {
|
|
552
574
|
id: ColumnBuilderWithTableName<ConvexSystemIdBuilder<TName>, TName>;
|
|
553
575
|
};
|
|
576
|
+
type InternalSystemFields<TName extends string> = {
|
|
577
|
+
_creationTime: ColumnBuilderWithTableName<ConvexSystemCreationTimeBuilder, TName>;
|
|
578
|
+
};
|
|
554
579
|
type SystemFieldAliases<TName extends string, TColumns extends Record<string, unknown> = {}> = 'createdAt' extends keyof TColumns ? {} : {
|
|
555
580
|
createdAt: ColumnBuilderWithTableName<ConvexSystemCreatedAtBuilder, TName>;
|
|
556
581
|
};
|
|
582
|
+
type SystemFieldsWithAliases<TName extends string, TColumns extends Record<string, unknown> = {}> = SystemFields<TName> & InternalSystemFields<TName> & SystemFieldAliases<TName, TColumns>;
|
|
557
583
|
//#endregion
|
|
558
584
|
//#region src/orm/builders/text.d.ts
|
|
559
585
|
/**
|
|
@@ -926,7 +952,6 @@ declare function or(...expressions: (FilterExpression<boolean> | undefined)[]):
|
|
|
926
952
|
declare function not(expression: FilterExpression<boolean>): UnaryExpression;
|
|
927
953
|
/**
|
|
928
954
|
* Array membership operator: field IN array
|
|
929
|
-
* Validates array is non-empty at construction time
|
|
930
955
|
*
|
|
931
956
|
* @example
|
|
932
957
|
* const filter = inArray(cols.status, ['active', 'pending']);
|
|
@@ -1644,7 +1669,7 @@ declare function rlsRole(name: string, config?: RlsRoleConfig): RlsRole;
|
|
|
1644
1669
|
//#endregion
|
|
1645
1670
|
//#region src/orm/rls/policies.d.ts
|
|
1646
1671
|
type RlsPolicyToOption = 'public' | 'current_role' | 'current_user' | 'session_user' | (string & {}) | RlsRole | RlsPolicyToOption[];
|
|
1647
|
-
type PolicyExpression<TCtx, TTable> = FilterExpression<boolean> | ((ctx: TCtx, table: TTable) => FilterExpression<boolean>);
|
|
1672
|
+
type PolicyExpression<TCtx, TTable> = FilterExpression<boolean> | ((ctx: TCtx, table: TTable) => FilterExpression<boolean> | Promise<FilterExpression<boolean>>);
|
|
1648
1673
|
interface RlsPolicyConfig<TCtx = any, TTable = ConvexTableWithColumns<any>> {
|
|
1649
1674
|
as?: 'permissive' | 'restrictive';
|
|
1650
1675
|
for?: 'all' | 'select' | 'insert' | 'update' | 'delete';
|
|
@@ -1684,6 +1709,7 @@ type ColumnsWithTableName<TColumns, TName extends string> = { [K in keyof TColum
|
|
|
1684
1709
|
fieldName: K extends string ? K : never;
|
|
1685
1710
|
};
|
|
1686
1711
|
} : TColumns[K] };
|
|
1712
|
+
type ColumnsWithSystemFields<TColumns, TName extends string> = ColumnsWithTableName<TColumns, TName> & (TColumns extends Record<string, unknown> ? SystemFieldsWithAliases<TName, TColumns> : SystemFieldsWithAliases<TName>);
|
|
1687
1713
|
type ConvexTableExtraConfigValue = ConvexIndexBuilder | ConvexSearchIndexBuilder | ConvexVectorIndexBuilder | ConvexForeignKeyBuilder | ConvexCheckBuilder | ConvexUniqueConstraintBuilder | ConvexDeletionBuilder | ConvexLifecycleBuilder | OrmTriggerLike | RlsPolicy;
|
|
1688
1714
|
type ConvexTableExtraConfig = Record<string, ConvexTableExtraConfigValue>;
|
|
1689
1715
|
type UnionToIntersection<T> = (T extends unknown ? (arg: T) => void : never) extends ((arg: infer U) => void) ? U : never;
|
|
@@ -1877,7 +1903,7 @@ type ConvexTableWithColumns<T extends TableConfig, Indexes extends GenericTableI
|
|
|
1877
1903
|
* index('by_email').on(t.email),
|
|
1878
1904
|
* ]);
|
|
1879
1905
|
*/
|
|
1880
|
-
type ConvexTableFnInternal = <TName extends string, TColumns, TExtraConfig extends ConvexTableExtraConfigValue[] | ConvexTableExtraConfig | undefined = undefined>(name: TName, columns: TColumns, extraConfig?: (self:
|
|
1906
|
+
type ConvexTableFnInternal = <TName extends string, TColumns, TExtraConfig extends ConvexTableExtraConfigValue[] | ConvexTableExtraConfig | undefined = undefined>(name: TName, columns: TColumns, extraConfig?: (self: ColumnsWithSystemFields<TColumns, TName>) => TExtraConfig) => ConvexTableWithColumns<{
|
|
1881
1907
|
name: TName;
|
|
1882
1908
|
columns: ColumnsWithTableName<TColumns, TName>;
|
|
1883
1909
|
}, InferDbIndexesFromExtraConfig<TExtraConfig>, InferSearchIndexesFromExtraConfig<TExtraConfig>, InferVectorIndexesFromExtraConfig<TExtraConfig>>;
|
|
@@ -2635,7 +2661,7 @@ declare class RelationalSelectChain<TSchema extends TablesRelationalConfig, TTab
|
|
|
2635
2661
|
interleaveBy(interleaveBy: string[]): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2636
2662
|
paginate(config: PaginateConfig): GelRelationalQuery<TSchema, TTableConfig, PaginatedResult<TRow>>;
|
|
2637
2663
|
pageByKey(pageByKey: FindManyPageByKeyConfig): GelRelationalQuery<TSchema, TTableConfig, KeyPageResult<TRow>>;
|
|
2638
|
-
first(): GelRelationalQuery<TSchema, TTableConfig, TRow |
|
|
2664
|
+
first(): GelRelationalQuery<TSchema, TTableConfig, TRow | null>;
|
|
2639
2665
|
firstOrThrow(): GelRelationalQuery<TSchema, TTableConfig, TRow>;
|
|
2640
2666
|
}
|
|
2641
2667
|
/**
|
|
@@ -2706,7 +2732,7 @@ declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TTa
|
|
|
2706
2732
|
*
|
|
2707
2733
|
* @template TConfig - Query configuration type (without limit)
|
|
2708
2734
|
* @param config - Optional query configuration (columns, with, where, orderBy, offset)
|
|
2709
|
-
* @returns Query promise that resolves to single result or
|
|
2735
|
+
* @returns Query promise that resolves to single result or null
|
|
2710
2736
|
*
|
|
2711
2737
|
* @example
|
|
2712
2738
|
* const user = await ctx.db.query.users.findFirst({
|
|
@@ -2714,8 +2740,8 @@ declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TTa
|
|
|
2714
2740
|
* with: { profile: true }
|
|
2715
2741
|
* });
|
|
2716
2742
|
*/
|
|
2717
|
-
findFirst<TConfig extends SearchFindFirstConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, SearchFindFirstConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> |
|
|
2718
|
-
findFirst<TConfig extends FindFirstConfigNoSearch<TSchema, TTableConfig>>(config?: KnownKeysOnly<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> |
|
|
2743
|
+
findFirst<TConfig extends SearchFindFirstConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, SearchFindFirstConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> | null>;
|
|
2744
|
+
findFirst<TConfig extends FindFirstConfigNoSearch<TSchema, TTableConfig>>(config?: KnownKeysOnly<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> | null>;
|
|
2719
2745
|
/**
|
|
2720
2746
|
* Find first row matching the query configuration, or throw if none exists.
|
|
2721
2747
|
*
|
package/dist/orm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as or, A as Brand, B as gte, D as unsetToken, E as OrmNotFoundError, F as contains, G as isNull, H as inArray, I as endsWith, J as lte, K as like, L as eq, M as TableName, N as and, O as RlsRole, P as between, Q as notInArray, R as fieldRef, T as desc, U as isFieldReference, V as ilike, W as isNotNull, X as not, Y as ne, Z as notBetween, _ as onInsert, a as getTableConfig, at as timestamp, b as rlsPolicy, c as uniqueIndex, ct as integer, d as scheduledMutationBatchFactory, dt as custom, et as startsWith, f as scheduledDeleteFactory, ft as json, g as onDelete, h as onChange, ht as bigint, i as getTableColumns, it as vector, j as Columns, k as rlsRole, l as vectorIndex, lt as id, m as deletion, mt as boolean, n as defineRelations, nt as foreignKey, o as index, ot as textEnum, p as convexTable, pt as bytes, q as lt, r as defineRelationsPart, rt as unique, s as searchIndex, st as text, t as defineSchema, tt as check, u as createOrm, ut as date, v as onUpdate, w as asc, x as extractRelationsConfig, y as RlsPolicy, z as gt } from "../orm-
|
|
1
|
+
import { $ as or, A as Brand, B as gte, D as unsetToken, E as OrmNotFoundError, F as contains, G as isNull, H as inArray, I as endsWith, J as lte, K as like, L as eq, M as TableName, N as and, O as RlsRole, P as between, Q as notInArray, R as fieldRef, T as desc, U as isFieldReference, V as ilike, W as isNotNull, X as not, Y as ne, Z as notBetween, _ as onInsert, a as getTableConfig, at as timestamp, b as rlsPolicy, c as uniqueIndex, ct as integer, d as scheduledMutationBatchFactory, dt as custom, et as startsWith, f as scheduledDeleteFactory, ft as json, g as onDelete, h as onChange, ht as bigint, i as getTableColumns, it as vector, j as Columns, k as rlsRole, l as vectorIndex, lt as id, m as deletion, mt as boolean, n as defineRelations, nt as foreignKey, o as index, ot as textEnum, p as convexTable, pt as bytes, q as lt, r as defineRelationsPart, rt as unique, s as searchIndex, st as text, t as defineSchema, tt as check, u as createOrm, ut as date, v as onUpdate, w as asc, x as extractRelationsConfig, y as RlsPolicy, z as gt } from "../orm-BKc-pwj_.js";
|
|
2
2
|
|
|
3
3
|
export { Brand, Columns, OrmNotFoundError, RlsPolicy, RlsRole, TableName, and, asc, between, bigint, boolean, bytes, check, contains, convexTable, createOrm, custom, date, defineRelations, defineRelationsPart, defineSchema, deletion, desc, endsWith, eq, extractRelationsConfig, fieldRef, foreignKey, getTableColumns, getTableConfig, gt, gte, id, ilike, inArray, index, integer, isFieldReference, isNotNull, isNull, json, like, lt, lte, ne, not, notBetween, notInArray, onChange, onDelete, onInsert, onUpdate, or, rlsPolicy, rlsRole, scheduledDeleteFactory, scheduledMutationBatchFactory, searchIndex, startsWith, text, textEnum, timestamp, unique, uniqueIndex, unsetToken, vector, vectorIndex };
|
|
@@ -875,13 +875,11 @@ function not(expression) {
|
|
|
875
875
|
}
|
|
876
876
|
/**
|
|
877
877
|
* Array membership operator: field IN array
|
|
878
|
-
* Validates array is non-empty at construction time
|
|
879
878
|
*
|
|
880
879
|
* @example
|
|
881
880
|
* const filter = inArray(cols.status, ['active', 'pending']);
|
|
882
881
|
*/
|
|
883
882
|
function inArray(col, values) {
|
|
884
|
-
if (!Array.isArray(values) || values.length === 0) throw new Error("inArray requires a non-empty array of values");
|
|
885
883
|
return new BinaryExpressionImpl("inArray", [fieldRef(resolveColumn(col).columnName), values]);
|
|
886
884
|
}
|
|
887
885
|
/**
|
|
@@ -1135,6 +1133,7 @@ const hydrateDateFieldsForRead = (table, value) => {
|
|
|
1135
1133
|
result[name] = hydrateTemporalReadValue(descriptor, rawCreationTime);
|
|
1136
1134
|
continue;
|
|
1137
1135
|
}
|
|
1136
|
+
if (!Object.hasOwn(result, name)) continue;
|
|
1138
1137
|
result[name] = hydrateTemporalReadValue(descriptor, result[name]);
|
|
1139
1138
|
}
|
|
1140
1139
|
return result;
|
|
@@ -1887,6 +1886,7 @@ function toConvexFilter(expression) {
|
|
|
1887
1886
|
case "inArray": {
|
|
1888
1887
|
const values = value;
|
|
1889
1888
|
return (q) => {
|
|
1889
|
+
if (values.length === 0) return q.eq(q.field("_id"), "__better_convex_never__");
|
|
1890
1890
|
return values.map((v) => q.eq(q.field(fieldName), v)).reduce((acc, cond) => q.or(acc, cond));
|
|
1891
1891
|
};
|
|
1892
1892
|
}
|
|
@@ -2068,13 +2068,13 @@ function roleMatches(policy, rls) {
|
|
|
2068
2068
|
if (targetRoles === "public") return true;
|
|
2069
2069
|
return targetRoles.some((role) => roles.includes(role));
|
|
2070
2070
|
}
|
|
2071
|
-
function resolveExpression(policy, checkType, ctx, table) {
|
|
2071
|
+
async function resolveExpression(policy, checkType, ctx, table) {
|
|
2072
2072
|
const candidate = checkType === "withCheck" ? policy.withCheck ?? policy.using : policy.using;
|
|
2073
2073
|
if (!candidate) return;
|
|
2074
|
-
if (typeof candidate === "function") return candidate(ctx, table);
|
|
2074
|
+
if (typeof candidate === "function") return await candidate(ctx, table);
|
|
2075
2075
|
return candidate;
|
|
2076
2076
|
}
|
|
2077
|
-
function evaluatePolicySet({ table, operation, checkType, row, rls }) {
|
|
2077
|
+
async function evaluatePolicySet({ table, operation, checkType, row, rls }) {
|
|
2078
2078
|
if (!isRlsEnabled(table)) return true;
|
|
2079
2079
|
if (rls?.mode === "skip") return true;
|
|
2080
2080
|
const ctx = rls?.ctx ?? {};
|
|
@@ -2082,18 +2082,24 @@ function evaluatePolicySet({ table, operation, checkType, row, rls }) {
|
|
|
2082
2082
|
if (policies.length === 0) return false;
|
|
2083
2083
|
const permissive = policies.filter((policy) => (policy.as ?? "permissive") !== "restrictive");
|
|
2084
2084
|
if (permissive.length === 0) return false;
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2085
|
+
let permissivePasses = false;
|
|
2086
|
+
for (const policy of permissive) {
|
|
2087
|
+
const expression = await resolveExpression(policy, checkType, ctx, table);
|
|
2088
|
+
if (!expression || evaluateFilter(row, expression)) {
|
|
2089
|
+
permissivePasses = true;
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
if (!permissivePasses) return false;
|
|
2094
|
+
const restrictive = policies.filter((policy) => (policy.as ?? "permissive") === "restrictive");
|
|
2095
|
+
for (const policy of restrictive) {
|
|
2096
|
+
const expression = await resolveExpression(policy, checkType, ctx, table);
|
|
2097
|
+
if (!expression) continue;
|
|
2098
|
+
if (!evaluateFilter(row, expression)) return false;
|
|
2099
|
+
}
|
|
2100
|
+
return true;
|
|
2095
2101
|
}
|
|
2096
|
-
function canSelectRow(options) {
|
|
2102
|
+
async function canSelectRow(options) {
|
|
2097
2103
|
return evaluatePolicySet({
|
|
2098
2104
|
table: options.table,
|
|
2099
2105
|
operation: "select",
|
|
@@ -2102,7 +2108,7 @@ function canSelectRow(options) {
|
|
|
2102
2108
|
rls: options.rls
|
|
2103
2109
|
});
|
|
2104
2110
|
}
|
|
2105
|
-
function canInsertRow(options) {
|
|
2111
|
+
async function canInsertRow(options) {
|
|
2106
2112
|
return evaluatePolicySet({
|
|
2107
2113
|
table: options.table,
|
|
2108
2114
|
operation: "insert",
|
|
@@ -2111,7 +2117,7 @@ function canInsertRow(options) {
|
|
|
2111
2117
|
rls: options.rls
|
|
2112
2118
|
});
|
|
2113
2119
|
}
|
|
2114
|
-
function canDeleteRow(options) {
|
|
2120
|
+
async function canDeleteRow(options) {
|
|
2115
2121
|
return evaluatePolicySet({
|
|
2116
2122
|
table: options.table,
|
|
2117
2123
|
operation: "delete",
|
|
@@ -2120,15 +2126,15 @@ function canDeleteRow(options) {
|
|
|
2120
2126
|
rls: options.rls
|
|
2121
2127
|
});
|
|
2122
2128
|
}
|
|
2123
|
-
function evaluateUpdateDecision(options) {
|
|
2124
|
-
const usingAllowed = evaluatePolicySet({
|
|
2129
|
+
async function evaluateUpdateDecision(options) {
|
|
2130
|
+
const usingAllowed = await evaluatePolicySet({
|
|
2125
2131
|
table: options.table,
|
|
2126
2132
|
operation: "update",
|
|
2127
2133
|
checkType: "using",
|
|
2128
2134
|
row: options.existingRow,
|
|
2129
2135
|
rls: options.rls
|
|
2130
2136
|
});
|
|
2131
|
-
const withCheckAllowed = evaluatePolicySet({
|
|
2137
|
+
const withCheckAllowed = await evaluatePolicySet({
|
|
2132
2138
|
table: options.table,
|
|
2133
2139
|
operation: "update",
|
|
2134
2140
|
checkType: "withCheck",
|
|
@@ -2141,14 +2147,16 @@ function evaluateUpdateDecision(options) {
|
|
|
2141
2147
|
withCheckAllowed
|
|
2142
2148
|
};
|
|
2143
2149
|
}
|
|
2144
|
-
function filterSelectRows(options) {
|
|
2150
|
+
async function filterSelectRows(options) {
|
|
2145
2151
|
if (!isRlsEnabled(options.table)) return options.rows;
|
|
2146
2152
|
if (options.rls?.mode === "skip") return options.rows;
|
|
2147
|
-
|
|
2153
|
+
const rows = [];
|
|
2154
|
+
for (const row of options.rows) if (await canSelectRow({
|
|
2148
2155
|
table: options.table,
|
|
2149
2156
|
row,
|
|
2150
2157
|
rls: options.rls
|
|
2151
|
-
}));
|
|
2158
|
+
})) rows.push(row);
|
|
2159
|
+
return rows;
|
|
2152
2160
|
}
|
|
2153
2161
|
|
|
2154
2162
|
//#endregion
|
|
@@ -2919,7 +2927,7 @@ var ConvexDeleteBuilder = class extends QueryPromise {
|
|
|
2919
2927
|
};
|
|
2920
2928
|
const fkBatchSize = isPaginated ? pagination.limit : batchSize;
|
|
2921
2929
|
for (const row of rows) {
|
|
2922
|
-
if (!canDeleteRow({
|
|
2930
|
+
if (!await canDeleteRow({
|
|
2923
2931
|
table: this.table,
|
|
2924
2932
|
row,
|
|
2925
2933
|
rls
|
|
@@ -3036,7 +3044,7 @@ var ConvexInsertBuilder = class extends QueryPromise {
|
|
|
3036
3044
|
const preparedValue = normalizeDateFieldsForWrite(this.table, applyDefaults(this.table, value));
|
|
3037
3045
|
const rls = getOrmContext(this.db)?.rls;
|
|
3038
3046
|
const tableName = getTableName(this.table);
|
|
3039
|
-
if (!canInsertRow({
|
|
3047
|
+
if (!await canInsertRow({
|
|
3040
3048
|
table: this.table,
|
|
3041
3049
|
row: preparedValue,
|
|
3042
3050
|
rls
|
|
@@ -3110,7 +3118,7 @@ var ConvexInsertBuilder = class extends QueryPromise {
|
|
|
3110
3118
|
...normalizedSet
|
|
3111
3119
|
};
|
|
3112
3120
|
const writeSet = normalizeDateFieldsForWrite(this.table, effectiveSet);
|
|
3113
|
-
const updateDecision = evaluateUpdateDecision({
|
|
3121
|
+
const updateDecision = await evaluateUpdateDecision({
|
|
3114
3122
|
table: this.table,
|
|
3115
3123
|
existingRow: existing,
|
|
3116
3124
|
updatedRow: {
|
|
@@ -4613,11 +4621,11 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
4613
4621
|
if (this.mode === "many") return selectedRows;
|
|
4614
4622
|
const first = selectedRows[0];
|
|
4615
4623
|
if (this.mode === "firstOrThrow" && first === void 0) throw new OrmNotFoundError(`Could not find ${this.tableConfig.name}.`, this.tableConfig.name);
|
|
4616
|
-
return first;
|
|
4624
|
+
return first ?? null;
|
|
4617
4625
|
}
|
|
4618
|
-
_applyRlsSelectFilter(rows, tableConfig) {
|
|
4626
|
+
async _applyRlsSelectFilter(rows, tableConfig) {
|
|
4619
4627
|
if (!rows.length || !tableConfig) return rows;
|
|
4620
|
-
return filterSelectRows({
|
|
4628
|
+
return await filterSelectRows({
|
|
4621
4629
|
table: tableConfig.table,
|
|
4622
4630
|
rows,
|
|
4623
4631
|
rls: this.rls
|
|
@@ -5598,7 +5606,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5598
5606
|
if (id === null || id === void 0) return null;
|
|
5599
5607
|
return this.db.get(id);
|
|
5600
5608
|
})).filter((row) => !!row);
|
|
5601
|
-
rows = this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5609
|
+
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5602
5610
|
if (orderSpecs.length > 0 && rows.length > 1) rows.sort((a, b) => this._compareByOrderSpecs(a, b, orderSpecs));
|
|
5603
5611
|
if (offset > 0) rows = rows.slice(offset);
|
|
5604
5612
|
if (typeof config.limit === "number") rows = rows.slice(0, config.limit);
|
|
@@ -5621,7 +5629,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5621
5629
|
absoluteMaxRows: pageByKey.absoluteMaxRows,
|
|
5622
5630
|
order: pageByKey.order
|
|
5623
5631
|
});
|
|
5624
|
-
let rows = this._applyRlsSelectFilter(page.page, this.tableConfig);
|
|
5632
|
+
let rows = await this._applyRlsSelectFilter(page.page, this.tableConfig);
|
|
5625
5633
|
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5626
5634
|
return {
|
|
5627
5635
|
page: await this._finalizeRows(rows),
|
|
@@ -5653,7 +5661,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5653
5661
|
maxScan
|
|
5654
5662
|
});
|
|
5655
5663
|
return {
|
|
5656
|
-
page: await this._finalizeRows(this._applyRlsSelectFilter(paginationResult.page, this.tableConfig)),
|
|
5664
|
+
page: await this._finalizeRows(await this._applyRlsSelectFilter(paginationResult.page, this.tableConfig)),
|
|
5657
5665
|
continueCursor: paginationResult.continueCursor,
|
|
5658
5666
|
isDone: paginationResult.isDone,
|
|
5659
5667
|
pageStatus: paginationResult.pageStatus,
|
|
@@ -5665,7 +5673,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5665
5673
|
const limit = this._resolveNonPaginatedLimit(config);
|
|
5666
5674
|
let rows = limit === void 0 ? await streamQuery.collect() : await streamQuery.take(offset > 0 ? offset + limit : limit);
|
|
5667
5675
|
if (offset > 0) rows = rows.slice(offset);
|
|
5668
|
-
rows = this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5676
|
+
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5669
5677
|
const selectedRows = await this._finalizeRows(rows);
|
|
5670
5678
|
return this._returnSelectedRows(selectedRows);
|
|
5671
5679
|
}
|
|
@@ -5698,7 +5706,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5698
5706
|
_score: score
|
|
5699
5707
|
};
|
|
5700
5708
|
});
|
|
5701
|
-
rows = this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5709
|
+
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5702
5710
|
const selectedRows = await this._finalizeRows(rows);
|
|
5703
5711
|
return this._returnSelectedRows(selectedRows);
|
|
5704
5712
|
}
|
|
@@ -5727,7 +5735,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5727
5735
|
numItems: config.limit
|
|
5728
5736
|
});
|
|
5729
5737
|
let pageRows = paginationResult.page;
|
|
5730
|
-
pageRows = this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5738
|
+
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5731
5739
|
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5732
5740
|
return {
|
|
5733
5741
|
page: await this._finalizeRows(pageRows),
|
|
@@ -5740,7 +5748,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5740
5748
|
const limit = this._resolveNonPaginatedLimit(config);
|
|
5741
5749
|
let rows = limit === void 0 ? await searchQuery.collect() : await searchQuery.take(offset > 0 ? offset + limit : limit);
|
|
5742
5750
|
if (offset > 0) rows = rows.slice(offset);
|
|
5743
|
-
rows = this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5751
|
+
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5744
5752
|
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5745
5753
|
const selectedRows = await this._finalizeRows(rows);
|
|
5746
5754
|
return this._returnSelectedRows(selectedRows);
|
|
@@ -5806,7 +5814,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5806
5814
|
maxScan
|
|
5807
5815
|
});
|
|
5808
5816
|
let pageRows = paginationResult.page;
|
|
5809
|
-
pageRows = this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5817
|
+
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5810
5818
|
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5811
5819
|
let pageWithRelations = pageRows;
|
|
5812
5820
|
if (this.config.with) pageWithRelations = await this._loadRelations(pageRows, this.config.with, 0, 3, this.edgeMetadata, this.tableConfig);
|
|
@@ -5825,7 +5833,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5825
5833
|
const paginateAfterPostFetchSort = usePostFetchSort && postFetchOrders.length > 0;
|
|
5826
5834
|
let rows = limit === void 0 || paginateAfterPostFetchSort ? await streamQuery.collect() : await streamQuery.take(offset > 0 ? offset + limit : limit);
|
|
5827
5835
|
if (!paginateAfterPostFetchSort && offset > 0) rows = rows.slice(offset);
|
|
5828
|
-
rows = this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5836
|
+
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5829
5837
|
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5830
5838
|
if (usePostFetchSort && postFetchOrders.length > 0) rows = rows.sort((a, b) => this._compareByOrderSpecs(a, b, postFetchOrders));
|
|
5831
5839
|
if (paginateAfterPostFetchSort) {
|
|
@@ -5857,7 +5865,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5857
5865
|
}));
|
|
5858
5866
|
let rows = Array.from(new Map(probeRows.flat().map((row) => [String(row._id), row])).values());
|
|
5859
5867
|
if (queryConfig.postFilters.length > 0) rows = rows.filter((row) => queryConfig.postFilters.every((filter) => this._evaluatePostFetchFilter(row, filter)));
|
|
5860
|
-
rows = this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5868
|
+
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5861
5869
|
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5862
5870
|
if (usePostFetchSort && postFetchOrders.length > 0) rows = rows.sort((a, b) => this._compareByOrderSpecs(a, b, postFetchOrders));
|
|
5863
5871
|
const offset = config.offset ?? 0;
|
|
@@ -5894,7 +5902,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5894
5902
|
maxScan
|
|
5895
5903
|
});
|
|
5896
5904
|
let pageRows = paginationResult.page;
|
|
5897
|
-
pageRows = this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5905
|
+
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5898
5906
|
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5899
5907
|
let pageWithRelations = pageRows;
|
|
5900
5908
|
if (this.config.with) pageWithRelations = await this._loadRelations(pageRows, this.config.with, 0, 3, this.edgeMetadata, this.tableConfig);
|
|
@@ -5928,7 +5936,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5928
5936
|
maxScan
|
|
5929
5937
|
});
|
|
5930
5938
|
let pageRows = paginationResult.page;
|
|
5931
|
-
pageRows = this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5939
|
+
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5932
5940
|
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5933
5941
|
let pageWithRelations = pageRows;
|
|
5934
5942
|
if (this.config.with) pageWithRelations = await this._loadRelations(pageRows, this.config.with, 0, 3, this.edgeMetadata, this.tableConfig);
|
|
@@ -5962,7 +5970,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5962
5970
|
numItems: config.limit
|
|
5963
5971
|
});
|
|
5964
5972
|
let pageRows = paginationResult.page;
|
|
5965
|
-
pageRows = this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5973
|
+
pageRows = await this._applyRlsSelectFilter(pageRows, this.tableConfig);
|
|
5966
5974
|
if (whereFilter) pageRows = await this._applyRelationsFilterToRows(pageRows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5967
5975
|
let pageWithRelations = pageRows;
|
|
5968
5976
|
if (this.config.with) pageWithRelations = await this._loadRelations(pageRows, this.config.with, 0, 3, this.edgeMetadata, this.tableConfig);
|
|
@@ -5988,7 +5996,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
5988
5996
|
let rows = limit === void 0 || paginateAfterPostFetchSort ? await query.collect() : await query.take(offset > 0 ? offset + limit : limit);
|
|
5989
5997
|
if (!paginateAfterPostFetchSort && offset > 0) rows = rows.slice(offset);
|
|
5990
5998
|
if (queryConfig.postFilters.length > 0) rows = rows.filter((row) => queryConfig.postFilters.every((filter) => this._evaluatePostFetchFilter(row, filter)));
|
|
5991
|
-
rows = this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5999
|
+
rows = await this._applyRlsSelectFilter(rows, this.tableConfig);
|
|
5992
6000
|
if (whereFilter) rows = await this._applyRelationsFilterToRows(rows, this.tableConfig, whereFilter, this.edgeMetadata, 0, 3, this.config.with);
|
|
5993
6001
|
if (usePostFetchSort && postFetchOrders.length > 0) rows = rows.sort((a, b) => this._compareByOrderSpecs(a, b, postFetchOrders));
|
|
5994
6002
|
if (paginateAfterPostFetchSort) {
|
|
@@ -6109,6 +6117,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
6109
6117
|
case "inArray": {
|
|
6110
6118
|
const values = normalizedValue;
|
|
6111
6119
|
return (q) => {
|
|
6120
|
+
if (values.length === 0) return q.eq(q.field("_id"), "__better_convex_never__");
|
|
6112
6121
|
return values.map((v) => q.eq(q.field(fieldName), v)).reduce((acc, cond) => q.or(acc, cond));
|
|
6113
6122
|
};
|
|
6114
6123
|
}
|
|
@@ -6280,7 +6289,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
6280
6289
|
const targetsByKey = /* @__PURE__ */ new Map();
|
|
6281
6290
|
for (const entry of fetched) targetsByKey.set(entry.key, entry.target ?? null);
|
|
6282
6291
|
let targets = Array.from(targetsByKey.values()).filter((value) => !!value);
|
|
6283
|
-
targets = this._applyRlsSelectFilter(targets, targetTableConfig);
|
|
6292
|
+
targets = await this._applyRlsSelectFilter(targets, targetTableConfig);
|
|
6284
6293
|
if (relationDefinition?.where) targets = targets.filter((target) => this._evaluateTableFilter(target, targetTableConfig, relationDefinition.where));
|
|
6285
6294
|
if (relationConfig && typeof relationConfig === "object" && "where" in relationConfig) {
|
|
6286
6295
|
const whereFilter = relationConfig.where;
|
|
@@ -6414,7 +6423,7 @@ var GelRelationalQuery = class extends QueryPromise {
|
|
|
6414
6423
|
return await query.collect();
|
|
6415
6424
|
})).flat();
|
|
6416
6425
|
}
|
|
6417
|
-
targets = this._applyRlsSelectFilter(targets, targetTableConfig);
|
|
6426
|
+
targets = await this._applyRlsSelectFilter(targets, targetTableConfig);
|
|
6418
6427
|
if (relationDefinition?.where) targets = targets.filter((target) => this._evaluateTableFilter(target, targetTableConfig, relationDefinition.where));
|
|
6419
6428
|
if (relationConfig && typeof relationConfig === "object" && "where" in relationConfig) {
|
|
6420
6429
|
const whereFilter = relationConfig.where;
|
|
@@ -6948,7 +6957,7 @@ var ConvexUpdateBuilder = class extends QueryPromise {
|
|
|
6948
6957
|
const rls = ormContext?.rls;
|
|
6949
6958
|
const foreignKeyGraph = ormContext?.foreignKeyGraph;
|
|
6950
6959
|
if (!foreignKeyGraph) throw new Error("Foreign key actions require orm.db(ctx) configured from createOrm({ schema, ... }).");
|
|
6951
|
-
const updates = rows.map((row) => {
|
|
6960
|
+
const updates = await Promise.all(rows.map(async (row) => {
|
|
6952
6961
|
const updatedRow = {
|
|
6953
6962
|
...row,
|
|
6954
6963
|
...effectiveSet
|
|
@@ -6956,14 +6965,14 @@ var ConvexUpdateBuilder = class extends QueryPromise {
|
|
|
6956
6965
|
return {
|
|
6957
6966
|
row,
|
|
6958
6967
|
updatedRow,
|
|
6959
|
-
decision: evaluateUpdateDecision({
|
|
6968
|
+
decision: await evaluateUpdateDecision({
|
|
6960
6969
|
table: this.table,
|
|
6961
6970
|
existingRow: row,
|
|
6962
6971
|
updatedRow,
|
|
6963
6972
|
rls
|
|
6964
6973
|
})
|
|
6965
6974
|
};
|
|
6966
|
-
});
|
|
6975
|
+
}));
|
|
6967
6976
|
if (updates.find(({ decision }) => decision.usingAllowed && !decision.withCheckAllowed)) throw new Error(`RLS policy violation for update on table "${tableName}"`);
|
|
6968
6977
|
const results = [];
|
|
6969
6978
|
let numAffected = 0;
|
|
@@ -8021,7 +8030,7 @@ const convexTableInternal = (name, columns, extraConfig) => {
|
|
|
8021
8030
|
configurable: true,
|
|
8022
8031
|
writable: false
|
|
8023
8032
|
});
|
|
8024
|
-
applyExtraConfig(rawTable, extraConfig?.(
|
|
8033
|
+
applyExtraConfig(rawTable, extraConfig?.(table));
|
|
8025
8034
|
return table;
|
|
8026
8035
|
};
|
|
8027
8036
|
const convexTableWithRLS = (name, columns, extraConfig) => {
|