@better-auth/core 1.4.0-beta.13 → 1.4.0-beta.15
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/.turbo/turbo-build.log +34 -58
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.d.cts +2 -6
- package/dist/api/index.d.ts +2 -6
- package/dist/api/index.js +1 -1
- package/dist/async_hooks/index.d.cts +1 -1
- package/dist/async_hooks/index.d.ts +1 -1
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.cts +14 -18
- package/dist/context/index.d.ts +14 -18
- package/dist/context/index.js +1 -1
- package/dist/{context-Bm0rm76r.js → context-BAOGRjRS.js} +30 -30
- package/dist/{context-7VgEbfs3.cjs → context-BRDf96na.cjs} +29 -29
- package/dist/db/adapter/index.d.cts +2 -6
- package/dist/db/adapter/index.d.ts +2 -6
- package/dist/db/index.cjs +17 -17
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.js +17 -17
- package/dist/env/index.d.cts +1 -1
- package/dist/env/index.d.ts +1 -1
- package/dist/error/index.d.cts +1 -1
- package/dist/error/index.d.ts +1 -1
- package/dist/{index-D5uj-vER.d.ts → index-B_YiOlcX.d.cts} +9 -9
- package/dist/index-Bab6W0hG.d.ts +7155 -0
- package/dist/index-CGS5U4X6.d.cts +7155 -0
- package/dist/{index-Dy_s5RNc.d.cts → index-CSISZQGm.d.ts} +9 -9
- package/dist/index.d.cts +3 -65
- package/dist/index.d.ts +3 -65
- package/dist/oauth2/index.cjs +1 -1
- package/dist/oauth2/index.d.cts +2 -2
- package/dist/oauth2/index.d.ts +2 -2
- package/dist/oauth2/index.js +1 -1
- package/dist/{oauth2-C8-hfKTF.cjs → oauth2-C4Pt8KMZ.cjs} +87 -87
- package/dist/{oauth2-CjVUvPq7.js → oauth2-CP3eVHS_.js} +88 -88
- package/dist/social-providers/index.cjs +963 -888
- package/dist/social-providers/index.d.cts +3 -4
- package/dist/social-providers/index.d.ts +3 -4
- package/dist/social-providers/index.js +1023 -948
- package/package.json +4 -3
- package/src/api/index.ts +3 -3
- package/src/context/endpoint-context.ts +1 -1
- package/src/context/index.ts +7 -7
- package/src/context/transaction.ts +2 -2
- package/src/db/adapter/index.ts +146 -128
- package/src/db/index.ts +11 -11
- package/src/db/plugin.ts +3 -3
- package/src/db/type.ts +47 -41
- package/src/env/index.ts +9 -9
- package/src/env/logger.test.ts +2 -2
- package/src/env/logger.ts +11 -9
- package/src/error/index.ts +1 -1
- package/src/oauth2/client-credentials-token.ts +9 -9
- package/src/oauth2/create-authorization-url.ts +12 -12
- package/src/oauth2/index.ts +10 -11
- package/src/oauth2/oauth-provider.ts +91 -74
- package/src/oauth2/refresh-access-token.ts +12 -12
- package/src/oauth2/validate-authorization-code.ts +13 -13
- package/src/social-providers/apple.ts +6 -6
- package/src/social-providers/atlassian.ts +23 -18
- package/src/social-providers/cognito.ts +17 -14
- package/src/social-providers/discord.ts +6 -6
- package/src/social-providers/dropbox.ts +3 -3
- package/src/social-providers/facebook.ts +10 -7
- package/src/social-providers/figma.ts +8 -5
- package/src/social-providers/github.ts +2 -2
- package/src/social-providers/gitlab.ts +7 -7
- package/src/social-providers/google.ts +15 -12
- package/src/social-providers/huggingface.ts +25 -23
- package/src/social-providers/index.ts +29 -26
- package/src/social-providers/kakao.ts +39 -39
- package/src/social-providers/kick.ts +3 -3
- package/src/social-providers/line.ts +10 -10
- package/src/social-providers/linear.ts +4 -4
- package/src/social-providers/linkedin.ts +3 -3
- package/src/social-providers/microsoft-entra-id.ts +15 -13
- package/src/social-providers/naver.ts +3 -3
- package/src/social-providers/notion.ts +9 -7
- package/src/social-providers/paybin.ts +122 -0
- package/src/social-providers/paypal.ts +29 -27
- package/src/social-providers/polar.ts +20 -18
- package/src/social-providers/reddit.ts +4 -4
- package/src/social-providers/roblox.ts +11 -8
- package/src/social-providers/salesforce.ts +22 -17
- package/src/social-providers/slack.ts +3 -3
- package/src/social-providers/spotify.ts +3 -3
- package/src/social-providers/tiktok.ts +30 -28
- package/src/social-providers/twitch.ts +6 -6
- package/src/social-providers/twitter.ts +47 -43
- package/src/social-providers/vk.ts +11 -10
- package/src/social-providers/zoom.ts +15 -13
- package/src/types/context.ts +23 -17
- package/src/types/index.ts +11 -10
- package/src/types/init-options.ts +1037 -932
- package/src/types/plugin-client.ts +44 -13
- package/src/types/plugin.ts +66 -52
- package/dist/helper-BH5srn6K.d.ts +0 -6
- package/dist/helper-ChPUVnMr.d.cts +0 -6
- package/dist/index-BCxkjvux.d.cts +0 -344
- package/dist/index-CZCOI9An.d.ts +0 -344
- package/dist/index-Cg7SVnu9.d.cts +0 -4645
- package/dist/index-DQNPxXof.d.ts +0 -262
- package/dist/index-DXj1sY8B.d.cts +0 -1772
- package/dist/index-DgTKobWC.d.ts +0 -1772
- package/dist/index-RfHoxHB4.d.ts +0 -4531
- package/dist/index-daoIWR6L.d.cts +0 -262
- /package/dist/{index-CR-gJyzm.d.ts → index-BzepAavo.d.cts} +0 -0
- /package/dist/{index-CilaMiAm.d.cts → index-DT7CRnvv.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/core",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
4
|
-
"description": "The most comprehensive authentication
|
|
3
|
+
"version": "1.4.0-beta.15",
|
|
4
|
+
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -174,9 +174,10 @@
|
|
|
174
174
|
"jose": "^6.1.0",
|
|
175
175
|
"kysely": "^0.28.5",
|
|
176
176
|
"nanostores": "^1.0.1",
|
|
177
|
-
"tsdown": "^0.15.
|
|
177
|
+
"tsdown": "^0.15.11"
|
|
178
178
|
},
|
|
179
179
|
"dependencies": {
|
|
180
|
+
"@standard-schema/spec": "^1.0.0",
|
|
180
181
|
"zod": "^4.1.5"
|
|
181
182
|
},
|
|
182
183
|
"peerDependencies": {
|
package/src/api/index.ts
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
type EndpointContext,
|
|
5
5
|
type EndpointOptions,
|
|
6
6
|
} from "better-call";
|
|
7
|
-
import type { AuthContext } from "../types";
|
|
8
7
|
import { runWithEndpointContext } from "../context";
|
|
8
|
+
import type { AuthContext } from "../types";
|
|
9
9
|
|
|
10
10
|
export const optionsMiddleware = createMiddleware(async () => {
|
|
11
11
|
/**
|
|
@@ -24,8 +24,8 @@ export const createAuthMiddleware = createMiddleware.create({
|
|
|
24
24
|
*/
|
|
25
25
|
createMiddleware(async () => {
|
|
26
26
|
return {} as {
|
|
27
|
-
returned?: unknown;
|
|
28
|
-
responseHeaders?: Headers;
|
|
27
|
+
returned?: unknown | undefined;
|
|
28
|
+
responseHeaders?: Headers | undefined;
|
|
29
29
|
};
|
|
30
30
|
}),
|
|
31
31
|
],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AsyncLocalStorage, getAsyncLocalStorage } from "../async_hooks";
|
|
2
1
|
import type { EndpointContext, InputContext } from "better-call";
|
|
2
|
+
import { type AsyncLocalStorage, getAsyncLocalStorage } from "../async_hooks";
|
|
3
3
|
import type { AuthContext } from "../types";
|
|
4
4
|
|
|
5
5
|
export type AuthEndpointContext = Partial<
|
package/src/context/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
2
|
+
type AuthEndpointContext,
|
|
3
|
+
getCurrentAuthContext,
|
|
4
|
+
getCurrentAuthContextAsyncLocalStorage,
|
|
5
|
+
runWithEndpointContext,
|
|
6
|
+
} from "./endpoint-context";
|
|
7
|
+
export {
|
|
3
8
|
getCurrentAdapter,
|
|
9
|
+
getCurrentDBAdapterAsyncLocalStorage,
|
|
4
10
|
runWithAdapter,
|
|
5
11
|
runWithTransaction,
|
|
6
12
|
} from "./transaction";
|
|
7
|
-
export {
|
|
8
|
-
getCurrentAuthContextAsyncLocalStorage,
|
|
9
|
-
getCurrentAuthContext,
|
|
10
|
-
runWithEndpointContext,
|
|
11
|
-
type AuthEndpointContext,
|
|
12
|
-
} from "./endpoint-context";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import { type AsyncLocalStorage, getAsyncLocalStorage } from "../async_hooks";
|
|
2
|
+
import type { DBAdapter, DBTransactionAdapter } from "../db/adapter";
|
|
3
3
|
|
|
4
4
|
let currentAdapterAsyncStorage: AsyncLocalStorage<DBTransactionAdapter> | null =
|
|
5
5
|
null;
|
package/src/db/adapter/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BetterAuthDBSchema, DBFieldAttribute } from "../type";
|
|
2
1
|
import type { BetterAuthOptions } from "../../types";
|
|
2
|
+
import type { BetterAuthDBSchema, DBFieldAttribute } from "../type";
|
|
3
3
|
|
|
4
4
|
export type DBAdapterDebugLogOption =
|
|
5
5
|
| boolean
|
|
@@ -8,14 +8,14 @@ export type DBAdapterDebugLogOption =
|
|
|
8
8
|
* Useful when you want to log only certain conditions.
|
|
9
9
|
*/
|
|
10
10
|
logCondition?: (() => boolean) | undefined;
|
|
11
|
-
create?: boolean;
|
|
12
|
-
update?: boolean;
|
|
13
|
-
updateMany?: boolean;
|
|
14
|
-
findOne?: boolean;
|
|
15
|
-
findMany?: boolean;
|
|
16
|
-
delete?: boolean;
|
|
17
|
-
deleteMany?: boolean;
|
|
18
|
-
count?: boolean;
|
|
11
|
+
create?: boolean | undefined;
|
|
12
|
+
update?: boolean | undefined;
|
|
13
|
+
updateMany?: boolean | undefined;
|
|
14
|
+
findOne?: boolean | undefined;
|
|
15
|
+
findMany?: boolean | undefined;
|
|
16
|
+
delete?: boolean | undefined;
|
|
17
|
+
deleteMany?: boolean | undefined;
|
|
18
|
+
count?: boolean | undefined;
|
|
19
19
|
}
|
|
20
20
|
| {
|
|
21
21
|
/**
|
|
@@ -40,11 +40,11 @@ export type DBAdapterSchemaCreation = {
|
|
|
40
40
|
* Append the file if it already exists.
|
|
41
41
|
* Note: This will not apply if `overwrite` is set to true.
|
|
42
42
|
*/
|
|
43
|
-
append?: boolean;
|
|
43
|
+
append?: boolean | undefined;
|
|
44
44
|
/**
|
|
45
45
|
* Overwrite the file if it already exists
|
|
46
46
|
*/
|
|
47
|
-
overwrite?: boolean;
|
|
47
|
+
overwrite?: boolean | undefined;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export interface DBAdapterFactoryConfig<
|
|
@@ -57,13 +57,13 @@ export interface DBAdapterFactoryConfig<
|
|
|
57
57
|
*
|
|
58
58
|
* @default false
|
|
59
59
|
*/
|
|
60
|
-
usePlural?: boolean;
|
|
60
|
+
usePlural?: boolean | undefined;
|
|
61
61
|
/**
|
|
62
62
|
* Enable debug logs.
|
|
63
63
|
*
|
|
64
64
|
* @default false
|
|
65
65
|
*/
|
|
66
|
-
debugLogs?: DBAdapterDebugLogOption;
|
|
66
|
+
debugLogs?: DBAdapterDebugLogOption | undefined;
|
|
67
67
|
/**
|
|
68
68
|
* Name of the adapter.
|
|
69
69
|
*
|
|
@@ -71,7 +71,7 @@ export interface DBAdapterFactoryConfig<
|
|
|
71
71
|
*
|
|
72
72
|
* @default `adapterId`
|
|
73
73
|
*/
|
|
74
|
-
adapterName?: string;
|
|
74
|
+
adapterName?: string | undefined;
|
|
75
75
|
/**
|
|
76
76
|
* Adapter id
|
|
77
77
|
*/
|
|
@@ -81,7 +81,7 @@ export interface DBAdapterFactoryConfig<
|
|
|
81
81
|
*
|
|
82
82
|
* @default true
|
|
83
83
|
*/
|
|
84
|
-
supportsNumericIds?: boolean;
|
|
84
|
+
supportsNumericIds?: boolean | undefined;
|
|
85
85
|
/**
|
|
86
86
|
* If the database doesn't support JSON columns, set this to `false`.
|
|
87
87
|
*
|
|
@@ -89,7 +89,7 @@ export interface DBAdapterFactoryConfig<
|
|
|
89
89
|
*
|
|
90
90
|
* @default false
|
|
91
91
|
*/
|
|
92
|
-
supportsJSON?: boolean;
|
|
92
|
+
supportsJSON?: boolean | undefined;
|
|
93
93
|
/**
|
|
94
94
|
* If the database doesn't support dates, set this to `false`.
|
|
95
95
|
*
|
|
@@ -97,7 +97,7 @@ export interface DBAdapterFactoryConfig<
|
|
|
97
97
|
*
|
|
98
98
|
* @default true
|
|
99
99
|
*/
|
|
100
|
-
supportsDates?: boolean;
|
|
100
|
+
supportsDates?: boolean | undefined;
|
|
101
101
|
/**
|
|
102
102
|
* If the database doesn't support booleans, set this to `false`.
|
|
103
103
|
*
|
|
@@ -105,7 +105,7 @@ export interface DBAdapterFactoryConfig<
|
|
|
105
105
|
*
|
|
106
106
|
* @default true
|
|
107
107
|
*/
|
|
108
|
-
supportsBooleans?: boolean;
|
|
108
|
+
supportsBooleans?: boolean | undefined;
|
|
109
109
|
/**
|
|
110
110
|
* Execute multiple operations in a transaction.
|
|
111
111
|
*
|
|
@@ -114,10 +114,13 @@ export interface DBAdapterFactoryConfig<
|
|
|
114
114
|
* @default false
|
|
115
115
|
*/
|
|
116
116
|
transaction?:
|
|
117
|
-
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
| (
|
|
118
|
+
| false
|
|
119
|
+
| (<R>(
|
|
120
|
+
callback: (trx: DBTransactionAdapter<Options>) => Promise<R>,
|
|
121
|
+
) => Promise<R>)
|
|
122
|
+
)
|
|
123
|
+
| undefined;
|
|
121
124
|
/**
|
|
122
125
|
* Disable id generation for the `create` method.
|
|
123
126
|
*
|
|
@@ -125,7 +128,7 @@ export interface DBAdapterFactoryConfig<
|
|
|
125
128
|
*
|
|
126
129
|
* @default false
|
|
127
130
|
*/
|
|
128
|
-
disableIdGeneration?: boolean;
|
|
131
|
+
disableIdGeneration?: boolean | undefined;
|
|
129
132
|
/**
|
|
130
133
|
* Map the keys of the input data.
|
|
131
134
|
*
|
|
@@ -146,7 +149,7 @@ export interface DBAdapterFactoryConfig<
|
|
|
146
149
|
* }
|
|
147
150
|
* ```
|
|
148
151
|
*/
|
|
149
|
-
mapKeysTransformInput?: Record<string, string
|
|
152
|
+
mapKeysTransformInput?: Record<string, string> | undefined;
|
|
150
153
|
/**
|
|
151
154
|
* Map the keys of the output data.
|
|
152
155
|
*
|
|
@@ -166,71 +169,75 @@ export interface DBAdapterFactoryConfig<
|
|
|
166
169
|
* }
|
|
167
170
|
* ```
|
|
168
171
|
*/
|
|
169
|
-
mapKeysTransformOutput?: Record<string, string
|
|
172
|
+
mapKeysTransformOutput?: Record<string, string> | undefined;
|
|
170
173
|
/**
|
|
171
174
|
* Custom transform input function.
|
|
172
175
|
*
|
|
173
176
|
* This function is used to transform the input data before it is saved to the database.
|
|
174
177
|
*/
|
|
175
|
-
customTransformInput?:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
178
|
+
customTransformInput?:
|
|
179
|
+
| ((props: {
|
|
180
|
+
data: any;
|
|
181
|
+
/**
|
|
182
|
+
* The fields of the model.
|
|
183
|
+
*/
|
|
184
|
+
fieldAttributes: DBFieldAttribute;
|
|
185
|
+
/**
|
|
186
|
+
* The field to transform.
|
|
187
|
+
*/
|
|
188
|
+
field: string;
|
|
189
|
+
/**
|
|
190
|
+
* The action which was called from the adapter.
|
|
191
|
+
*/
|
|
192
|
+
action: "create" | "update";
|
|
193
|
+
/**
|
|
194
|
+
* The model name.
|
|
195
|
+
*/
|
|
196
|
+
model: string;
|
|
197
|
+
/**
|
|
198
|
+
* The schema of the user's Better-Auth instance.
|
|
199
|
+
*/
|
|
200
|
+
schema: BetterAuthDBSchema;
|
|
201
|
+
/**
|
|
202
|
+
* The options of the user's Better-Auth instance.
|
|
203
|
+
*/
|
|
204
|
+
options: Options;
|
|
205
|
+
}) => any)
|
|
206
|
+
| undefined;
|
|
202
207
|
/**
|
|
203
208
|
* Custom transform output function.
|
|
204
209
|
*
|
|
205
210
|
* This function is used to transform the output data before it is returned to the user.
|
|
206
211
|
*/
|
|
207
|
-
customTransformOutput?:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
212
|
+
customTransformOutput?:
|
|
213
|
+
| ((props: {
|
|
214
|
+
data: any;
|
|
215
|
+
/**
|
|
216
|
+
* The fields of the model.
|
|
217
|
+
*/
|
|
218
|
+
fieldAttributes: DBFieldAttribute;
|
|
219
|
+
/**
|
|
220
|
+
* The field to transform.
|
|
221
|
+
*/
|
|
222
|
+
field: string;
|
|
223
|
+
/**
|
|
224
|
+
* The fields to select.
|
|
225
|
+
*/
|
|
226
|
+
select: string[];
|
|
227
|
+
/**
|
|
228
|
+
* The model name.
|
|
229
|
+
*/
|
|
230
|
+
model: string;
|
|
231
|
+
/**
|
|
232
|
+
* The schema of the user's Better-Auth instance.
|
|
233
|
+
*/
|
|
234
|
+
schema: BetterAuthDBSchema;
|
|
235
|
+
/**
|
|
236
|
+
* The options of the user's Better-Auth instance.
|
|
237
|
+
*/
|
|
238
|
+
options: Options;
|
|
239
|
+
}) => any)
|
|
240
|
+
| undefined;
|
|
234
241
|
/**
|
|
235
242
|
* Custom ID generator function.
|
|
236
243
|
*
|
|
@@ -251,19 +258,19 @@ export interface DBAdapterFactoryConfig<
|
|
|
251
258
|
* }
|
|
252
259
|
* ```
|
|
253
260
|
*/
|
|
254
|
-
customIdGenerator?: (props: { model: string }) => string;
|
|
261
|
+
customIdGenerator?: ((props: { model: string }) => string) | undefined;
|
|
255
262
|
/**
|
|
256
263
|
* Whether to disable the transform output.
|
|
257
264
|
* Do not use this option unless you know what you are doing.
|
|
258
265
|
* @default false
|
|
259
266
|
*/
|
|
260
|
-
disableTransformOutput?: boolean;
|
|
267
|
+
disableTransformOutput?: boolean | undefined;
|
|
261
268
|
/**
|
|
262
269
|
* Whether to disable the transform input.
|
|
263
270
|
* Do not use this option unless you know what you are doing.
|
|
264
271
|
* @default false
|
|
265
272
|
*/
|
|
266
|
-
disableTransformInput?: boolean;
|
|
273
|
+
disableTransformInput?: boolean | undefined;
|
|
267
274
|
}
|
|
268
275
|
|
|
269
276
|
export type Where = {
|
|
@@ -271,23 +278,26 @@ export type Where = {
|
|
|
271
278
|
* @default eq
|
|
272
279
|
*/
|
|
273
280
|
operator?:
|
|
274
|
-
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
| (
|
|
282
|
+
| "eq"
|
|
283
|
+
| "ne"
|
|
284
|
+
| "lt"
|
|
285
|
+
| "lte"
|
|
286
|
+
| "gt"
|
|
287
|
+
| "gte"
|
|
288
|
+
| "in"
|
|
289
|
+
| "not_in"
|
|
290
|
+
| "contains"
|
|
291
|
+
| "starts_with"
|
|
292
|
+
| "ends_with"
|
|
293
|
+
)
|
|
294
|
+
| undefined;
|
|
285
295
|
value: string | number | boolean | string[] | number[] | Date | null;
|
|
286
296
|
field: string;
|
|
287
297
|
/**
|
|
288
298
|
* @default AND
|
|
289
299
|
*/
|
|
290
|
-
connector?: "AND" | "OR";
|
|
300
|
+
connector?: ("AND" | "OR") | undefined;
|
|
291
301
|
};
|
|
292
302
|
|
|
293
303
|
export type DBTransactionAdapter<
|
|
@@ -299,30 +309,35 @@ export type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
|
299
309
|
create: <T extends Record<string, any>, R = T>(data: {
|
|
300
310
|
model: string;
|
|
301
311
|
data: Omit<T, "id">;
|
|
302
|
-
select?: string[];
|
|
312
|
+
select?: string[] | undefined;
|
|
303
313
|
/**
|
|
304
314
|
* By default, any `id` provided in `data` will be ignored.
|
|
305
315
|
*
|
|
306
316
|
* If you want to force the `id` to be the same as the `data.id`, set this to `true`.
|
|
307
317
|
*/
|
|
308
|
-
forceAllowId?: boolean;
|
|
318
|
+
forceAllowId?: boolean | undefined;
|
|
309
319
|
}) => Promise<R>;
|
|
310
320
|
findOne: <T>(data: {
|
|
311
321
|
model: string;
|
|
312
322
|
where: Where[];
|
|
313
|
-
select?: string[];
|
|
323
|
+
select?: string[] | undefined;
|
|
314
324
|
}) => Promise<T | null>;
|
|
315
325
|
findMany: <T>(data: {
|
|
316
326
|
model: string;
|
|
317
|
-
where?: Where[];
|
|
318
|
-
limit?: number;
|
|
319
|
-
sortBy?:
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
327
|
+
where?: Where[] | undefined;
|
|
328
|
+
limit?: number | undefined;
|
|
329
|
+
sortBy?:
|
|
330
|
+
| {
|
|
331
|
+
field: string;
|
|
332
|
+
direction: "asc" | "desc";
|
|
333
|
+
}
|
|
334
|
+
| undefined;
|
|
335
|
+
offset?: number | undefined;
|
|
324
336
|
}) => Promise<T[]>;
|
|
325
|
-
count: (data: {
|
|
337
|
+
count: (data: {
|
|
338
|
+
model: string;
|
|
339
|
+
where?: Where[] | undefined;
|
|
340
|
+
}) => Promise<number>;
|
|
326
341
|
/**
|
|
327
342
|
* ⚠︎ Update may not return the updated data
|
|
328
343
|
* if multiple where clauses are provided
|
|
@@ -351,13 +366,14 @@ export type DBAdapter<Options extends BetterAuthOptions = BetterAuthOptions> = {
|
|
|
351
366
|
* @param options
|
|
352
367
|
* @param file - file path if provided by the user
|
|
353
368
|
*/
|
|
354
|
-
createSchema?:
|
|
355
|
-
options: Options,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
369
|
+
createSchema?:
|
|
370
|
+
| ((options: Options, file?: string) => Promise<DBAdapterSchemaCreation>)
|
|
371
|
+
| undefined;
|
|
372
|
+
options?:
|
|
373
|
+
| ({
|
|
374
|
+
adapterConfig: DBAdapterFactoryConfig<Options>;
|
|
375
|
+
} & CustomAdapter["options"])
|
|
376
|
+
| undefined;
|
|
361
377
|
};
|
|
362
378
|
|
|
363
379
|
export type CleanedWhere = Required<Where>;
|
|
@@ -370,7 +386,7 @@ export interface CustomAdapter {
|
|
|
370
386
|
}: {
|
|
371
387
|
model: string;
|
|
372
388
|
data: T;
|
|
373
|
-
select?: string[];
|
|
389
|
+
select?: string[] | undefined;
|
|
374
390
|
}) => Promise<T>;
|
|
375
391
|
update: <T>(data: {
|
|
376
392
|
model: string;
|
|
@@ -389,7 +405,7 @@ export interface CustomAdapter {
|
|
|
389
405
|
}: {
|
|
390
406
|
model: string;
|
|
391
407
|
where: CleanedWhere[];
|
|
392
|
-
select?: string[];
|
|
408
|
+
select?: string[] | undefined;
|
|
393
409
|
}) => Promise<T | null>;
|
|
394
410
|
findMany: <T>({
|
|
395
411
|
model,
|
|
@@ -399,10 +415,10 @@ export interface CustomAdapter {
|
|
|
399
415
|
offset,
|
|
400
416
|
}: {
|
|
401
417
|
model: string;
|
|
402
|
-
where?: CleanedWhere[];
|
|
418
|
+
where?: CleanedWhere[] | undefined;
|
|
403
419
|
limit: number;
|
|
404
|
-
sortBy?: { field: string; direction: "asc" | "desc" };
|
|
405
|
-
offset?: number;
|
|
420
|
+
sortBy?: { field: string; direction: "asc" | "desc" } | undefined;
|
|
421
|
+
offset?: number | undefined;
|
|
406
422
|
}) => Promise<T[]>;
|
|
407
423
|
delete: ({
|
|
408
424
|
model,
|
|
@@ -423,18 +439,20 @@ export interface CustomAdapter {
|
|
|
423
439
|
where,
|
|
424
440
|
}: {
|
|
425
441
|
model: string;
|
|
426
|
-
where?: CleanedWhere[];
|
|
442
|
+
where?: CleanedWhere[] | undefined;
|
|
427
443
|
}) => Promise<number>;
|
|
428
|
-
createSchema?:
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
444
|
+
createSchema?:
|
|
445
|
+
| ((props: {
|
|
446
|
+
/**
|
|
447
|
+
* The file the user may have passed in to the `generate` command as the expected schema file output path.
|
|
448
|
+
*/
|
|
449
|
+
file?: string;
|
|
450
|
+
/**
|
|
451
|
+
* The tables from the user's Better-Auth instance schema.
|
|
452
|
+
*/
|
|
453
|
+
tables: BetterAuthDBSchema;
|
|
454
|
+
}) => Promise<DBAdapterSchemaCreation>)
|
|
455
|
+
| undefined;
|
|
438
456
|
/**
|
|
439
457
|
* Your adapter's options.
|
|
440
458
|
*/
|
package/src/db/index.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
+
import type { BetterAuthPluginDBSchema } from "./plugin";
|
|
1
2
|
import type {
|
|
3
|
+
BetterAuthDBSchema,
|
|
2
4
|
DBFieldAttribute,
|
|
3
5
|
DBFieldAttributeConfig,
|
|
4
6
|
DBFieldType,
|
|
5
7
|
DBPrimitive,
|
|
6
|
-
BetterAuthDBSchema,
|
|
7
8
|
} from "./type";
|
|
8
|
-
|
|
9
|
+
|
|
9
10
|
export type { BetterAuthPluginDBSchema } from "./plugin";
|
|
10
|
-
export type
|
|
11
|
+
export { type Account, accountSchema } from "./schema/account";
|
|
12
|
+
export { type RateLimit, rateLimitSchema } from "./schema/rate-limit";
|
|
13
|
+
export { type Session, sessionSchema } from "./schema/session";
|
|
11
14
|
export { coreSchema } from "./schema/shared";
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export { sessionSchema, type Session } from "./schema/session";
|
|
15
|
-
export { verificationSchema, type Verification } from "./schema/verification";
|
|
16
|
-
export { rateLimitSchema, type RateLimit } from "./schema/rate-limit";
|
|
17
|
-
|
|
15
|
+
export { type User, userSchema } from "./schema/user";
|
|
16
|
+
export { type Verification, verificationSchema } from "./schema/verification";
|
|
18
17
|
export type {
|
|
18
|
+
BetterAuthDBSchema,
|
|
19
19
|
DBFieldAttribute,
|
|
20
20
|
DBFieldAttributeConfig,
|
|
21
21
|
DBFieldType,
|
|
22
|
-
DBPrimitive,
|
|
23
|
-
BetterAuthDBSchema,
|
|
24
22
|
DBPreservedModels,
|
|
23
|
+
DBPrimitive,
|
|
24
|
+
SecondaryStorage,
|
|
25
25
|
} from "./type";
|
|
26
26
|
|
|
27
27
|
/**
|
package/src/db/plugin.ts
CHANGED
|
@@ -3,9 +3,9 @@ import type { DBFieldAttribute } from "./type";
|
|
|
3
3
|
export type BetterAuthPluginDBSchema = {
|
|
4
4
|
[table in string]: {
|
|
5
5
|
fields: {
|
|
6
|
-
[field
|
|
6
|
+
[field: string]: DBFieldAttribute;
|
|
7
7
|
};
|
|
8
|
-
disableMigration?: boolean;
|
|
9
|
-
modelName?: string;
|
|
8
|
+
disableMigration?: boolean | undefined;
|
|
9
|
+
modelName?: string | undefined;
|
|
10
10
|
};
|
|
11
11
|
};
|