@convex-dev/better-auth 0.10.6 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-options.d.ts +1 -1
- package/dist/auth-options.d.ts.map +1 -1
- package/dist/auth.js +1 -1
- package/dist/auth.js.map +1 -1
- package/dist/client/adapter-utils.d.ts +3 -3
- package/dist/client/adapter-utils.js +1 -1
- package/dist/client/adapter-utils.js.map +1 -1
- package/dist/client/adapter.d.ts.map +1 -1
- package/dist/client/adapter.js +14 -13
- package/dist/client/adapter.js.map +1 -1
- package/dist/client/create-api.d.ts +4 -2
- package/dist/client/create-api.d.ts.map +1 -1
- package/dist/client/create-api.js +2 -0
- package/dist/client/create-api.js.map +1 -1
- package/dist/client/create-client.d.ts.map +1 -1
- package/dist/client/create-client.js +3 -0
- package/dist/client/create-client.js.map +1 -1
- package/dist/component/_generated/component.d.ts +4 -8
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/adapter.d.ts +3 -1
- package/dist/component/adapter.d.ts.map +1 -1
- package/dist/component/adapterTest.d.ts +8 -15
- package/dist/component/adapterTest.d.ts.map +1 -1
- package/dist/component/adapterTest.js +390 -61
- package/dist/component/adapterTest.js.map +1 -1
- package/dist/nextjs/index.js +1 -1
- package/dist/nextjs/index.js.map +1 -1
- package/dist/plugins/convex/index.d.ts +2 -1
- package/dist/plugins/convex/index.d.ts.map +1 -1
- package/dist/plugins/convex/index.js +5 -3
- package/dist/plugins/convex/index.js.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +0 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react-start/index.js +1 -1
- package/dist/react-start/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +4 -3
- package/src/auth-options.ts +1 -1
- package/src/auth.ts +1 -1
- package/src/client/adapter-utils.ts +1 -1
- package/src/client/adapter.test.ts +24 -440
- package/src/client/adapter.ts +18 -14
- package/src/client/create-api.ts +3 -1
- package/src/client/create-client.ts +3 -0
- package/src/component/_generated/component.ts +4 -8
- package/src/component/adapterTest.ts +457 -100
- package/src/nextjs/index.ts +1 -1
- package/src/plugins/convex/index.ts +6 -4
- package/src/react/index.tsx +0 -2
- package/src/react-start/index.ts +1 -1
- package/src/utils/index.ts +3 -1
package/src/client/adapter.ts
CHANGED
|
@@ -84,15 +84,21 @@ type ConvexCleanedWhere<TableName extends TableNames = TableNames> = Where & {
|
|
|
84
84
|
field: keyof WithoutSystemFields<Doc<TableName>> & string;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
const parseWhere = (
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const parseWhere = (
|
|
88
|
+
where?: (Where & { join?: undefined }) | (Where & { join?: undefined })[]
|
|
89
|
+
): ConvexCleanedWhere[] => {
|
|
90
|
+
if (!where) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const whereArray = Array.isArray(where) ? where : [where];
|
|
94
|
+
return whereArray.map((w) => {
|
|
95
|
+
if (w.value instanceof Date) {
|
|
90
96
|
return {
|
|
91
|
-
...
|
|
92
|
-
value:
|
|
97
|
+
...w,
|
|
98
|
+
value: w.value.getTime(),
|
|
93
99
|
};
|
|
94
100
|
}
|
|
95
|
-
return
|
|
101
|
+
return w;
|
|
96
102
|
}) as ConvexCleanedWhere[];
|
|
97
103
|
};
|
|
98
104
|
|
|
@@ -121,6 +127,7 @@ export const convexAdapter = <
|
|
|
121
127
|
transaction: false,
|
|
122
128
|
supportsNumericIds: false,
|
|
123
129
|
supportsJSON: false,
|
|
130
|
+
supportsDates: false,
|
|
124
131
|
supportsArrays: true,
|
|
125
132
|
usePlural: false,
|
|
126
133
|
mapKeysTransformInput: {
|
|
@@ -129,8 +136,6 @@ export const convexAdapter = <
|
|
|
129
136
|
mapKeysTransformOutput: {
|
|
130
137
|
_id: "id",
|
|
131
138
|
},
|
|
132
|
-
// Dates provided as strings
|
|
133
|
-
supportsDates: false,
|
|
134
139
|
// Convert dates to numbers. This aligns with how
|
|
135
140
|
// Convex stores _creationTime and avoids a breaking change.
|
|
136
141
|
customTransformInput: ({ data, fieldAttributes }) => {
|
|
@@ -180,7 +185,7 @@ export const convexAdapter = <
|
|
|
180
185
|
const result = await ctx.runQuery(api.adapter.findOne, {
|
|
181
186
|
...data,
|
|
182
187
|
model: data.model as TableNames,
|
|
183
|
-
where: parseWhere(
|
|
188
|
+
where: parseWhere(w),
|
|
184
189
|
});
|
|
185
190
|
if (result) {
|
|
186
191
|
return result;
|
|
@@ -197,6 +202,7 @@ export const convexAdapter = <
|
|
|
197
202
|
if (data.offset) {
|
|
198
203
|
throw new Error("offset not supported");
|
|
199
204
|
}
|
|
205
|
+
|
|
200
206
|
if (data.where?.some((w) => w.connector === "OR")) {
|
|
201
207
|
const results = await asyncMap(data.where, async (w) =>
|
|
202
208
|
handlePagination(
|
|
@@ -204,7 +210,7 @@ export const convexAdapter = <
|
|
|
204
210
|
return await ctx.runQuery(api.adapter.findMany, {
|
|
205
211
|
...data,
|
|
206
212
|
model: data.model as TableNames,
|
|
207
|
-
where: parseWhere(
|
|
213
|
+
where: parseWhere(w),
|
|
208
214
|
paginationOpts,
|
|
209
215
|
});
|
|
210
216
|
},
|
|
@@ -213,12 +219,10 @@ export const convexAdapter = <
|
|
|
213
219
|
);
|
|
214
220
|
const docs = unique(results.flatMap((r) => r.docs));
|
|
215
221
|
if (data.sortBy) {
|
|
216
|
-
|
|
222
|
+
return sortBy(docs, [
|
|
217
223
|
prop(data.sortBy.field),
|
|
218
224
|
data.sortBy.direction,
|
|
219
225
|
]);
|
|
220
|
-
console.log(result);
|
|
221
|
-
return result;
|
|
222
226
|
}
|
|
223
227
|
return docs;
|
|
224
228
|
}
|
|
@@ -244,7 +248,7 @@ export const convexAdapter = <
|
|
|
244
248
|
return await ctx.runQuery(api.adapter.findMany, {
|
|
245
249
|
...data,
|
|
246
250
|
model: data.model as TableNames,
|
|
247
|
-
where: parseWhere(
|
|
251
|
+
where: parseWhere(w),
|
|
248
252
|
paginationOpts,
|
|
249
253
|
});
|
|
250
254
|
})
|
package/src/client/create-api.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "./adapter-utils.js";
|
|
19
19
|
import { getAuthTables } from "better-auth/db";
|
|
20
20
|
import type { TableNames } from "../component/_generated/dataModel.js";
|
|
21
|
-
import type { BetterAuthOptions } from "better-auth";
|
|
21
|
+
import type { BetterAuthOptions } from "better-auth/minimal";
|
|
22
22
|
|
|
23
23
|
const whereValidator = (
|
|
24
24
|
schema: SchemaDefinition<any, any>,
|
|
@@ -112,6 +112,7 @@ export const createApi = <Schema extends SchemaDefinition<any, any>>(
|
|
|
112
112
|
),
|
|
113
113
|
where: v.optional(v.array(adapterWhereValidator)),
|
|
114
114
|
select: v.optional(v.array(v.string())),
|
|
115
|
+
join: v.optional(v.any()),
|
|
115
116
|
},
|
|
116
117
|
handler: async (ctx, args) => {
|
|
117
118
|
return await listOne(ctx, schema, betterAuthSchema, args);
|
|
@@ -131,6 +132,7 @@ export const createApi = <Schema extends SchemaDefinition<any, any>>(
|
|
|
131
132
|
})
|
|
132
133
|
),
|
|
133
134
|
offset: v.optional(v.number()),
|
|
135
|
+
join: v.optional(v.any()),
|
|
134
136
|
paginationOpts: paginationOptsValidator,
|
|
135
137
|
},
|
|
136
138
|
handler: async (ctx, args) => {
|
|
@@ -354,12 +354,15 @@ export const createClient = <
|
|
|
354
354
|
const path = staticAuth.options.basePath ?? "/api/auth";
|
|
355
355
|
const authRequestHandler = httpActionGeneric(async (ctx, request) => {
|
|
356
356
|
if (config?.verbose) {
|
|
357
|
+
// eslint-disable-next-line no-console
|
|
357
358
|
console.log("options.baseURL", staticAuth.options.baseURL);
|
|
359
|
+
// eslint-disable-next-line no-console
|
|
358
360
|
console.log("request headers", request.headers);
|
|
359
361
|
}
|
|
360
362
|
const auth = createAuth(ctx as any);
|
|
361
363
|
const response = await auth.handler(request);
|
|
362
364
|
if (config?.verbose) {
|
|
365
|
+
// eslint-disable-next-line no-console
|
|
363
366
|
console.log("response headers", response.headers);
|
|
364
367
|
}
|
|
365
368
|
return response;
|
|
@@ -934,6 +934,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
934
934
|
"query",
|
|
935
935
|
"internal",
|
|
936
936
|
{
|
|
937
|
+
join?: any;
|
|
937
938
|
limit?: number;
|
|
938
939
|
model:
|
|
939
940
|
| "user"
|
|
@@ -988,6 +989,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
988
989
|
"query",
|
|
989
990
|
"internal",
|
|
990
991
|
{
|
|
992
|
+
join?: any;
|
|
991
993
|
model:
|
|
992
994
|
| "user"
|
|
993
995
|
| "session"
|
|
@@ -2000,13 +2002,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
2000
2002
|
>;
|
|
2001
2003
|
};
|
|
2002
2004
|
adapterTest: {
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
delete: FunctionReference<"mutation", "internal", any, any, Name>;
|
|
2006
|
-
deleteMany: FunctionReference<"mutation", "internal", any, any, Name>;
|
|
2007
|
-
findMany: FunctionReference<"query", "internal", any, any, Name>;
|
|
2008
|
-
findOne: FunctionReference<"query", "internal", any, any, Name>;
|
|
2009
|
-
update: FunctionReference<"mutation", "internal", any, any, Name>;
|
|
2010
|
-
updateMany: FunctionReference<"mutation", "internal", any, any, Name>;
|
|
2005
|
+
runCustomTests: FunctionReference<"action", "internal", any, any, Name>;
|
|
2006
|
+
runTests: FunctionReference<"action", "internal", any, any, Name>;
|
|
2011
2007
|
};
|
|
2012
2008
|
};
|