payload-auth 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +17 -0
- package/dist/authjs/index.d.ts +1 -0
- package/dist/authjs/index.js +3 -0
- package/dist/authjs/index.js.map +1 -0
- package/dist/better-auth/adapter/dev/bin/run.d.ts +1 -0
- package/dist/better-auth/adapter/dev/bin/run.js +64 -0
- package/dist/better-auth/adapter/dev/bin/run.js.map +1 -0
- package/dist/better-auth/adapter/dev/bin/schema.d.ts +22 -0
- package/dist/better-auth/adapter/dev/bin/schema.js +160 -0
- package/dist/better-auth/adapter/dev/bin/schema.js.map +1 -0
- package/dist/better-auth/adapter/dev/collections.d.ts +3 -0
- package/dist/better-auth/adapter/dev/collections.js +212 -0
- package/dist/better-auth/adapter/dev/collections.js.map +1 -0
- package/dist/better-auth/adapter/dev/index.d.ts +3 -0
- package/dist/better-auth/adapter/dev/index.js +168 -0
- package/dist/better-auth/adapter/dev/index.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +23 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +326 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +23 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts +4 -0
- package/dist/better-auth/adapter/generate-schema/index.js +19 -0
- package/dist/better-auth/adapter/generate-schema/index.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +2 -0
- package/dist/better-auth/adapter/generate-schema/utils.js +20 -0
- package/dist/better-auth/adapter/generate-schema/utils.js.map +1 -0
- package/dist/better-auth/adapter/index.d.ts +5 -0
- package/dist/better-auth/adapter/index.js +578 -0
- package/dist/better-auth/adapter/index.js.map +1 -0
- package/dist/better-auth/adapter/test/adapter.test.d.ts +1 -0
- package/dist/better-auth/adapter/test/adapter.test.js +181 -0
- package/dist/better-auth/adapter/test/adapter.test.js.map +1 -0
- package/dist/better-auth/adapter/test/better-auth-adapter-test.d.ts +7 -0
- package/dist/better-auth/adapter/test/better-auth-adapter-test.js +425 -0
- package/dist/better-auth/adapter/test/better-auth-adapter-test.js.map +1 -0
- package/dist/better-auth/adapter/test/schema.test.d.ts +1 -0
- package/dist/better-auth/adapter/test/schema.test.js +796 -0
- package/dist/better-auth/adapter/test/schema.test.js.map +1 -0
- package/dist/better-auth/adapter/test/test_payload1/schema.d.ts +23 -0
- package/dist/better-auth/adapter/test/test_payload1/schema.js +177 -0
- package/dist/better-auth/adapter/test/test_payload1/schema.js.map +1 -0
- package/dist/better-auth/adapter/test/test_payload2/schema.d.ts +23 -0
- package/dist/better-auth/adapter/test/test_payload2/schema.js +167 -0
- package/dist/better-auth/adapter/test/test_payload2/schema.js.map +1 -0
- package/dist/better-auth/adapter/test/test_payload3/schema.d.ts +23 -0
- package/dist/better-auth/adapter/test/test_payload3/schema.js +198 -0
- package/dist/better-auth/adapter/test/test_payload3/schema.js.map +1 -0
- package/dist/better-auth/adapter/transform/index.d.ts +16 -0
- package/dist/better-auth/adapter/transform/index.js +252 -0
- package/dist/better-auth/adapter/transform/index.js.map +1 -0
- package/dist/better-auth/adapter/types.d.ts +6 -0
- package/dist/better-auth/adapter/types.js +3 -0
- package/dist/better-auth/adapter/types.js.map +1 -0
- package/dist/better-auth/index.d.ts +6 -0
- package/dist/better-auth/index.js +8 -0
- package/dist/better-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.d.ts +7 -0
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js +47 -0
- package/dist/better-auth/plugin/collections/accounts/hooks/sync-password-to-user.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.d.ts +6 -0
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js +106 -0
- package/dist/better-auth/plugin/collections/users/endpoints/refresh-token.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-login.d.ts +11 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-login.js +71 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-login.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.d.ts +6 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.js +49 -0
- package/dist/better-auth/plugin/collections/users/hooks/after-logout.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/before-login.d.ts +5 -0
- package/dist/better-auth/plugin/collections/users/hooks/before-login.js +18 -0
- package/dist/better-auth/plugin/collections/users/hooks/before-login.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.d.ts +5 -0
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js +33 -0
- package/dist/better-auth/plugin/collections/users/hooks/clean-up-user-after-delete.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.d.ts +2 -0
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js +14 -0
- package/dist/better-auth/plugin/collections/users/hooks/on-verified-change.js.map +1 -0
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.d.ts +7 -0
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.js +82 -0
- package/dist/better-auth/plugin/collections/users/hooks/sync-account.js.map +1 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +29 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +46 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-ip.js +31 -0
- package/dist/better-auth/plugin/helpers/get-ip.js.map +1 -0
- package/dist/better-auth/plugin/helpers/index.d.ts +1 -0
- package/dist/better-auth/plugin/helpers/index.js +3 -0
- package/dist/better-auth/plugin/helpers/index.js.map +1 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.d.ts +104 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.js +186 -0
- package/dist/better-auth/plugin/helpers/serialize-cookie.js.map +1 -0
- package/dist/better-auth/plugin/index.d.ts +7 -0
- package/dist/better-auth/plugin/index.js +64 -0
- package/dist/better-auth/plugin/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/auth-strategy.d.ts +8 -0
- package/dist/better-auth/plugin/lib/auth-strategy.js +48 -0
- package/dist/better-auth/plugin/lib/auth-strategy.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collection-configs.d.ts +11 -0
- package/dist/better-auth/plugin/lib/build-collection-configs.js +1558 -0
- package/dist/better-auth/plugin/lib/build-collection-configs.js.map +1 -0
- package/dist/better-auth/plugin/lib/config.d.ts +41 -0
- package/dist/better-auth/plugin/lib/config.js +43 -0
- package/dist/better-auth/plugin/lib/config.js.map +1 -0
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.d.ts +7 -0
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js +24 -0
- package/dist/better-auth/plugin/lib/ensure-password-set-before-create.js.map +1 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +5 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js +9 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.d.ts +9 -0
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.js +52 -0
- package/dist/better-auth/plugin/lib/get-required-collection-slugs.js.map +1 -0
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +6 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js +13 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/password.d.ts +25 -0
- package/dist/better-auth/plugin/lib/password.js +63 -0
- package/dist/better-auth/plugin/lib/password.js.map +1 -0
- package/dist/better-auth/plugin/lib/payload-access.d.ts +14 -0
- package/dist/better-auth/plugin/lib/payload-access.js +64 -0
- package/dist/better-auth/plugin/lib/payload-access.js.map +1 -0
- package/dist/better-auth/plugin/lib/prepare-session-data.d.ts +21 -0
- package/dist/better-auth/plugin/lib/prepare-session-data.js +42 -0
- package/dist/better-auth/plugin/lib/prepare-session-data.js.map +1 -0
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.d.ts +15 -0
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js +30 -0
- package/dist/better-auth/plugin/lib/respect-save-to-jwt-fields-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-auth-options.d.ts +5 -0
- package/dist/better-auth/plugin/lib/sanitize-auth-options.js +298 -0
- package/dist/better-auth/plugin/lib/sanitize-auth-options.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons.d.ts +5 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons.js +222 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/login-redirect.d.ts +1 -0
- package/dist/better-auth/plugin/payload/components/login-redirect.js +6 -0
- package/dist/better-auth/plugin/payload/components/login-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/logo.d.ts +1 -0
- package/dist/better-auth/plugin/payload/components/logo.js +36 -0
- package/dist/better-auth/plugin/payload/components/logo.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/logout.d.ts +1 -0
- package/dist/better-auth/plugin/payload/components/logout.js +61 -0
- package/dist/better-auth/plugin/payload/components/logout.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/sign-in.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/sign-in.js +384 -0
- package/dist/better-auth/plugin/payload/components/sign-in.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/sign-up.d.ts +6 -0
- package/dist/better-auth/plugin/payload/components/sign-up.js +502 -0
- package/dist/better-auth/plugin/payload/components/sign-up.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/styles.css +73 -0
- package/dist/better-auth/plugin/payload/components/ui/button.d.ts +10 -0
- package/dist/better-auth/plugin/payload/components/ui/button.js +42 -0
- package/dist/better-auth/plugin/payload/components/ui/button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/card.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/ui/card.js +55 -0
- package/dist/better-auth/plugin/payload/components/ui/card.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/checkbox.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/ui/checkbox.js +23 -0
- package/dist/better-auth/plugin/payload/components/ui/checkbox.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/cn.d.ts +2 -0
- package/dist/better-auth/plugin/payload/components/ui/cn.js +7 -0
- package/dist/better-auth/plugin/payload/components/ui/cn.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/input.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/ui/input.js +14 -0
- package/dist/better-auth/plugin/payload/components/ui/input.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/label.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/ui/label.js +15 -0
- package/dist/better-auth/plugin/payload/components/ui/label.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/ui/password-input.d.ts +2 -0
- package/dist/better-auth/plugin/payload/components/ui/password-input.js +55 -0
- package/dist/better-auth/plugin/payload/components/ui/password-input.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts +3 -0
- package/dist/better-auth/plugin/payload/exports/client.js +5 -0
- package/dist/better-auth/plugin/payload/exports/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +5 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js +7 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.d.ts +4 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.js +112 -0
- package/dist/better-auth/plugin/payload/views/create-first-admin/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/login/index.d.ts +4 -0
- package/dist/better-auth/plugin/payload/views/login/index.js +78 -0
- package/dist/better-auth/plugin/payload/views/login/index.js.map +1 -0
- package/dist/better-auth/plugin/types.d.ts +224 -0
- package/dist/better-auth/plugin/types.js +3 -0
- package/dist/better-auth/plugin/types.js.map +1 -0
- package/dist/better-auth/types.d.ts +2 -0
- package/dist/better-auth/types.js +4 -0
- package/dist/better-auth/types.js.map +1 -0
- package/dist/clerk/index.d.ts +1 -0
- package/dist/clerk/index.js +3 -0
- package/dist/clerk/index.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/kinde/index.d.ts +1 -0
- package/dist/kinde/index.js +3 -0
- package/dist/kinde/index.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { betterAuth } from 'better-auth';
|
|
2
|
+
import { afterAll, beforeAll, describe, expect, it, test } from 'vitest';
|
|
3
|
+
import { payloadAdapter } from 'payload-auth/better-auth/adapter';
|
|
4
|
+
import { runAdapterTest } from './better-auth-adapter-test.js';
|
|
5
|
+
import { getPayload } from '../dev/index.js';
|
|
6
|
+
describe('Handle Payload Adapter', async ()=>{
|
|
7
|
+
it('should successfully add the Payload Adapter', async ()=>{
|
|
8
|
+
const payload = await getPayload();
|
|
9
|
+
const auth = betterAuth({
|
|
10
|
+
database: payloadAdapter(payload)
|
|
11
|
+
});
|
|
12
|
+
expect(auth).toBeDefined();
|
|
13
|
+
expect(auth.options.database).toBeDefined();
|
|
14
|
+
expect(auth.options.database({}).id).toEqual('payload');
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
function deleteAll(payload) {
|
|
18
|
+
beforeAll(async ()=>{
|
|
19
|
+
// delete all users and sessions
|
|
20
|
+
const res = await payload.delete({
|
|
21
|
+
collection: 'user',
|
|
22
|
+
where: {
|
|
23
|
+
id: {
|
|
24
|
+
exists: true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
console.log('before users: ', res.docs.length, res.errors);
|
|
29
|
+
const res2 = await payload.delete({
|
|
30
|
+
collection: 'session',
|
|
31
|
+
where: {
|
|
32
|
+
id: {
|
|
33
|
+
exists: true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
console.log('before sessions: ', res2.docs.length, res2.errors);
|
|
38
|
+
const res3 = await payload.delete({
|
|
39
|
+
collection: 'account',
|
|
40
|
+
where: {
|
|
41
|
+
id: {
|
|
42
|
+
exists: true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
console.log('before accounts: ', res3.docs.length, res3.errors);
|
|
47
|
+
const res4 = await payload.delete({
|
|
48
|
+
collection: 'verification',
|
|
49
|
+
where: {
|
|
50
|
+
id: {
|
|
51
|
+
exists: true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
console.log('before verification: ', res4.docs.length, res4.errors);
|
|
56
|
+
});
|
|
57
|
+
afterAll(async ()=>{
|
|
58
|
+
const res2 = await payload.delete({
|
|
59
|
+
collection: 'session',
|
|
60
|
+
where: {
|
|
61
|
+
id: {
|
|
62
|
+
exists: true
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
console.log('after sessions: ', res2.docs.length, res2.errors);
|
|
67
|
+
const res3 = await payload.delete({
|
|
68
|
+
collection: 'account',
|
|
69
|
+
where: {
|
|
70
|
+
id: {
|
|
71
|
+
exists: true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
console.log('after accounts: ', res3.docs.length, res3.errors);
|
|
76
|
+
const res = await payload.delete({
|
|
77
|
+
collection: 'user',
|
|
78
|
+
where: {
|
|
79
|
+
id: {
|
|
80
|
+
exists: true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
console.log('after users: ', res.docs.length, res.errors);
|
|
85
|
+
const res4 = await payload.delete({
|
|
86
|
+
collection: 'verification',
|
|
87
|
+
where: {
|
|
88
|
+
id: {
|
|
89
|
+
exists: true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
console.log('after verification: ', res4.docs.length, res4.errors);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
describe('Run BetterAuth Adapter tests', async ()=>{
|
|
97
|
+
const payload = await getPayload();
|
|
98
|
+
deleteAll(payload);
|
|
99
|
+
const adapter = payloadAdapter(payload, {
|
|
100
|
+
enableDebugLogs: true
|
|
101
|
+
});
|
|
102
|
+
await runAdapterTest({
|
|
103
|
+
getAdapter: async (customOptions = {
|
|
104
|
+
session: {
|
|
105
|
+
fields: {
|
|
106
|
+
userId: 'user'
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
account: {
|
|
110
|
+
fields: {
|
|
111
|
+
userId: 'user'
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
})=>{
|
|
115
|
+
return adapter({
|
|
116
|
+
...customOptions
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
skipGenerateIdTest: true
|
|
120
|
+
});
|
|
121
|
+
test('should find many with offset and limit', async ()=>{
|
|
122
|
+
// At this point, `user` contains 8 rows.
|
|
123
|
+
// offset of 2 returns 6 rows
|
|
124
|
+
// limit of 2 returns 2 rows
|
|
125
|
+
const res = await adapter({}).findMany({
|
|
126
|
+
model: 'user',
|
|
127
|
+
offset: 2,
|
|
128
|
+
limit: 2
|
|
129
|
+
});
|
|
130
|
+
expect(res.length).toBe(2);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('Authentication Flow Tests', async ()=>{
|
|
134
|
+
const testUser = {
|
|
135
|
+
email: 'test-email@email.com',
|
|
136
|
+
password: 'password12345',
|
|
137
|
+
name: 'Test Name'
|
|
138
|
+
};
|
|
139
|
+
const payload = await getPayload();
|
|
140
|
+
deleteAll(payload);
|
|
141
|
+
const auth = betterAuth({
|
|
142
|
+
database: payloadAdapter(payload, {
|
|
143
|
+
enableDebugLogs: true
|
|
144
|
+
}),
|
|
145
|
+
emailAndPassword: {
|
|
146
|
+
enabled: true
|
|
147
|
+
},
|
|
148
|
+
session: {
|
|
149
|
+
fields: {
|
|
150
|
+
userId: 'user'
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
account: {
|
|
154
|
+
fields: {
|
|
155
|
+
userId: 'user'
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
it('should successfully sign up a new user', async ()=>{
|
|
160
|
+
const user = await auth.api.signUpEmail({
|
|
161
|
+
body: {
|
|
162
|
+
email: testUser.email,
|
|
163
|
+
password: testUser.password,
|
|
164
|
+
name: testUser.name
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
expect(user).toBeDefined();
|
|
168
|
+
});
|
|
169
|
+
it('should successfully sign in an existing user', async ()=>{
|
|
170
|
+
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
|
171
|
+
const user = await auth.api.signInEmail({
|
|
172
|
+
body: {
|
|
173
|
+
email: testUser.email,
|
|
174
|
+
password: testUser.password
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
expect(user.user).toBeDefined();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=adapter.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/test/adapter.test.ts"],"sourcesContent":["import { betterAuth, type BetterAuthOptions } from 'better-auth'\nimport { afterAll, beforeAll, describe, expect, it, test } from 'vitest'\nimport { payloadAdapter } from 'payload-auth/better-auth/adapter'\nimport { runAdapterTest } from './better-auth-adapter-test.js'\nimport { getPayload } from '../dev/index.js'\nimport { BasePayload } from 'payload'\n\ndescribe('Handle Payload Adapter', async () => {\n it('should successfully add the Payload Adapter', async () => {\n const payload = await getPayload()\n\n const auth = betterAuth({\n database: payloadAdapter(payload),\n })\n\n expect(auth).toBeDefined()\n expect(auth.options.database).toBeDefined()\n expect(auth.options.database({}).id).toEqual('payload')\n })\n})\n\nfunction deleteAll(payload: BasePayload) {\n beforeAll(async () => {\n // delete all users and sessions\n const res = await payload.delete({\n collection: 'user',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('before users: ', res.docs.length, res.errors)\n const res2 = await payload.delete({\n collection: 'session',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('before sessions: ', res2.docs.length, res2.errors)\n const res3 = await payload.delete({\n collection: 'account',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('before accounts: ', res3.docs.length, res3.errors)\n const res4 = await payload.delete({\n collection: 'verification',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('before verification: ', res4.docs.length, res4.errors)\n })\n afterAll(async () => {\n const res2 = await payload.delete({\n collection: 'session',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('after sessions: ', res2.docs.length, res2.errors)\n const res3 = await payload.delete({\n collection: 'account',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('after accounts: ', res3.docs.length, res3.errors)\n const res = await payload.delete({\n collection: 'user',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('after users: ', res.docs.length, res.errors)\n\n const res4 = await payload.delete({\n collection: 'verification',\n where: {\n id: {\n exists: true,\n },\n },\n })\n console.log('after verification: ', res4.docs.length, res4.errors)\n })\n}\n\ndescribe('Run BetterAuth Adapter tests', async () => {\n const payload = await getPayload()\n\n deleteAll(payload)\n\n const adapter = payloadAdapter(payload, {\n enableDebugLogs: true,\n })\n\n await runAdapterTest({\n getAdapter: async (\n customOptions = {\n session: {\n fields: {\n userId: 'user',\n },\n },\n account: {\n fields: {\n userId: 'user',\n },\n },\n },\n ) => {\n return adapter({ ...customOptions })\n },\n skipGenerateIdTest: true,\n })\n test('should find many with offset and limit', async () => {\n // At this point, `user` contains 8 rows.\n // offset of 2 returns 6 rows\n // limit of 2 returns 2 rows\n const res = await adapter({}).findMany({\n model: 'user',\n offset: 2,\n limit: 2,\n })\n expect(res.length).toBe(2)\n })\n})\n\ndescribe('Authentication Flow Tests', async () => {\n const testUser = {\n email: 'test-email@email.com',\n password: 'password12345',\n name: 'Test Name',\n }\n const payload = await getPayload()\n\n deleteAll(payload)\n\n const auth = betterAuth({\n database: payloadAdapter(payload, {\n enableDebugLogs: true,\n }),\n emailAndPassword: {\n enabled: true,\n },\n session: {\n fields: {\n userId: 'user',\n },\n },\n account: {\n fields: {\n userId: 'user',\n },\n },\n })\n\n it('should successfully sign up a new user', async () => {\n const user = await auth.api.signUpEmail({\n body: {\n email: testUser.email,\n password: testUser.password,\n name: testUser.name,\n },\n })\n expect(user).toBeDefined()\n })\n\n it('should successfully sign in an existing user', async () => {\n await new Promise((resolve) => setTimeout(resolve, 2000))\n const user = await auth.api.signInEmail({\n body: {\n email: testUser.email,\n password: testUser.password,\n },\n })\n\n expect(user.user).toBeDefined()\n })\n})\n"],"names":["betterAuth","afterAll","beforeAll","describe","expect","it","test","payloadAdapter","runAdapterTest","getPayload","payload","auth","database","toBeDefined","options","id","toEqual","deleteAll","res","delete","collection","where","exists","console","log","docs","length","errors","res2","res3","res4","adapter","enableDebugLogs","getAdapter","customOptions","session","fields","userId","account","skipGenerateIdTest","findMany","model","offset","limit","toBe","testUser","email","password","name","emailAndPassword","enabled","user","api","signUpEmail","body","Promise","resolve","setTimeout","signInEmail"],"mappings":"AAAA,SAASA,UAAU,QAAgC,cAAa;AAChE,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,IAAI,QAAQ,SAAQ;AACxE,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,UAAU,QAAQ,kBAAiB;AAG5CN,SAAS,0BAA0B;IACjCE,GAA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OAAOc,IAAIQ,MAAM,EAAEkB,IAAI,CAAC;IAC1B;AACF;AAEAzC,SAAS,6BAA6B;IACpC,MAAM0C,WAAW;QACfC,OAAO;QACPC,UAAU;QACVC,MAAM;IACR;IACA,MAAMtC,UAAU,MAAMD;IAEtBQ,UAAUP;IAEV,MAAMC,OAAOX,WAAW;QACtBY,UAAUL,eAAeG,SAAS;YAChCsB,iBAAiB;QACnB;QACAiB,kBAAkB;YAChBC,SAAS;QACX;QACAf,SAAS;YACPC,QAAQ;gBACNC,QAAQ;YACV;QACF;QACAC,SAAS;YACPF,QAAQ;gBACNC,QAAQ;YACV;QACF;IACF;IAEAhC,GAAG,0CAA0C;QAC3C,MAAM8C,OAAO,MAAMxC,KAAKyC,GAAG,CAACC,WAAW,CAAC;YACtCC,MAAM;gBACJR,OAAOD,SAASC,KAAK;gBACrBC,UAAUF,SAASE,QAAQ;gBAC3BC,MAAMH,SAASG,IAAI;YACrB;QACF;QACA5C,OAAO+C,MAAMtC,WAAW;IAC1B;IAEAR,GAAG,gDAAgD;QACjD,MAAM,IAAIkD,QAAQ,CAACC,UAAYC,WAAWD,SAAS;QACnD,MAAML,OAAO,MAAMxC,KAAKyC,GAAG,CAACM,WAAW,CAAC;YACtCJ,MAAM;gBACJR,OAAOD,SAASC,KAAK;gBACrBC,UAAUF,SAASE,QAAQ;YAC7B;QACF;QAEA3C,OAAO+C,KAAKA,IAAI,EAAEtC,WAAW;IAC/B;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Adapter, BetterAuthOptions } from 'better-auth';
|
|
2
|
+
interface AdapterTestOptions {
|
|
3
|
+
getAdapter: (customOptions?: Omit<BetterAuthOptions, 'database'>) => Promise<Adapter>;
|
|
4
|
+
skipGenerateIdTest?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function runAdapterTest(opts: AdapterTestOptions): Promise<void>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { generateId } from 'better-auth';
|
|
3
|
+
export async function runAdapterTest(opts) {
|
|
4
|
+
const adapter = await opts.getAdapter();
|
|
5
|
+
const user = {
|
|
6
|
+
id: '1',
|
|
7
|
+
name: 'user',
|
|
8
|
+
email: 'user@email.com',
|
|
9
|
+
emailVerified: true,
|
|
10
|
+
createdAt: new Date(),
|
|
11
|
+
updatedAt: new Date()
|
|
12
|
+
};
|
|
13
|
+
test('create model', async ()=>{
|
|
14
|
+
const res = await adapter.create({
|
|
15
|
+
model: 'user',
|
|
16
|
+
data: user
|
|
17
|
+
});
|
|
18
|
+
expect({
|
|
19
|
+
name: res.name,
|
|
20
|
+
email: res.email
|
|
21
|
+
}).toEqual({
|
|
22
|
+
name: user.name,
|
|
23
|
+
email: user.email
|
|
24
|
+
});
|
|
25
|
+
user.id = res.id;
|
|
26
|
+
});
|
|
27
|
+
test('find model', async ()=>{
|
|
28
|
+
const res = await adapter.findOne({
|
|
29
|
+
model: 'user',
|
|
30
|
+
where: [
|
|
31
|
+
{
|
|
32
|
+
field: 'id',
|
|
33
|
+
value: user.id
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
expect({
|
|
38
|
+
name: res?.name,
|
|
39
|
+
email: res?.email
|
|
40
|
+
}).toEqual({
|
|
41
|
+
name: user.name,
|
|
42
|
+
email: user.email
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
test('find model without id', async ()=>{
|
|
46
|
+
const res = await adapter.findOne({
|
|
47
|
+
model: 'user',
|
|
48
|
+
where: [
|
|
49
|
+
{
|
|
50
|
+
field: 'email',
|
|
51
|
+
value: user.email
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
expect({
|
|
56
|
+
name: res?.name,
|
|
57
|
+
email: res?.email
|
|
58
|
+
}).toEqual({
|
|
59
|
+
name: user.name,
|
|
60
|
+
email: user.email
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
test('find model with select', async ()=>{
|
|
64
|
+
const res = await adapter.findOne({
|
|
65
|
+
model: 'user',
|
|
66
|
+
where: [
|
|
67
|
+
{
|
|
68
|
+
field: 'id',
|
|
69
|
+
value: user.id
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
select: [
|
|
73
|
+
'email'
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
expect(res).toEqual({
|
|
77
|
+
id: user.id,
|
|
78
|
+
email: user.email
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
test('update model', async ()=>{
|
|
82
|
+
const newEmail = 'updated@email.com';
|
|
83
|
+
const res = await adapter.update({
|
|
84
|
+
model: 'user',
|
|
85
|
+
where: [
|
|
86
|
+
{
|
|
87
|
+
field: 'id',
|
|
88
|
+
value: user.id
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
update: {
|
|
92
|
+
email: newEmail
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
expect(res).toMatchObject({
|
|
96
|
+
email: newEmail,
|
|
97
|
+
name: user.name
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
test('should find many', async ()=>{
|
|
101
|
+
const res = await adapter.findMany({
|
|
102
|
+
model: 'user'
|
|
103
|
+
});
|
|
104
|
+
expect(res.length).toBe(1);
|
|
105
|
+
});
|
|
106
|
+
test('should find many with where', async ()=>{
|
|
107
|
+
const user = await adapter.create({
|
|
108
|
+
model: 'user',
|
|
109
|
+
data: {
|
|
110
|
+
id: '2',
|
|
111
|
+
name: 'user2',
|
|
112
|
+
email: 'test@email.com',
|
|
113
|
+
emailVerified: true,
|
|
114
|
+
createdAt: new Date(),
|
|
115
|
+
updatedAt: new Date()
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const res = await adapter.findMany({
|
|
119
|
+
model: 'user',
|
|
120
|
+
where: [
|
|
121
|
+
{
|
|
122
|
+
field: 'id',
|
|
123
|
+
value: user.id
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
expect(res.length).toBe(1);
|
|
128
|
+
});
|
|
129
|
+
test('should find many with operators', async ()=>{
|
|
130
|
+
const newUser = await adapter.create({
|
|
131
|
+
model: 'user',
|
|
132
|
+
data: {
|
|
133
|
+
id: '3',
|
|
134
|
+
name: 'user',
|
|
135
|
+
email: 'test-email2@email.com',
|
|
136
|
+
emailVerified: true,
|
|
137
|
+
createdAt: new Date(),
|
|
138
|
+
updatedAt: new Date()
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const res = await adapter.findMany({
|
|
142
|
+
model: 'user',
|
|
143
|
+
where: [
|
|
144
|
+
{
|
|
145
|
+
field: 'id',
|
|
146
|
+
operator: 'in',
|
|
147
|
+
value: [
|
|
148
|
+
user.id,
|
|
149
|
+
newUser.id
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
});
|
|
154
|
+
expect(res.length).toBe(2);
|
|
155
|
+
});
|
|
156
|
+
test('should work with reference fields', async ()=>{
|
|
157
|
+
let token = null;
|
|
158
|
+
const user = await adapter.create({
|
|
159
|
+
model: 'user',
|
|
160
|
+
data: {
|
|
161
|
+
id: '4',
|
|
162
|
+
name: 'user',
|
|
163
|
+
email: 'my-email@email.com',
|
|
164
|
+
emailVerified: true,
|
|
165
|
+
createdAt: new Date(),
|
|
166
|
+
updatedAt: new Date()
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const session = await adapter.create({
|
|
170
|
+
model: 'session',
|
|
171
|
+
data: {
|
|
172
|
+
id: '1',
|
|
173
|
+
token: generateId(),
|
|
174
|
+
createdAt: new Date(),
|
|
175
|
+
updatedAt: new Date(),
|
|
176
|
+
userId: user.id,
|
|
177
|
+
expiresAt: new Date()
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
token = session.token;
|
|
181
|
+
const res = await adapter.findOne({
|
|
182
|
+
model: 'session',
|
|
183
|
+
where: [
|
|
184
|
+
{
|
|
185
|
+
field: 'userId',
|
|
186
|
+
value: user.id
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
});
|
|
190
|
+
const resToken = await adapter.findOne({
|
|
191
|
+
model: 'session',
|
|
192
|
+
where: [
|
|
193
|
+
{
|
|
194
|
+
field: 'token',
|
|
195
|
+
value: token
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
expect(res).toMatchObject({
|
|
200
|
+
userId: user.id
|
|
201
|
+
});
|
|
202
|
+
expect(resToken).toMatchObject({
|
|
203
|
+
userId: user.id
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
test('should find many with sortBy', async ()=>{
|
|
207
|
+
await adapter.create({
|
|
208
|
+
model: 'user',
|
|
209
|
+
data: {
|
|
210
|
+
id: '5',
|
|
211
|
+
name: 'a',
|
|
212
|
+
email: 'a@email.com',
|
|
213
|
+
emailVerified: true,
|
|
214
|
+
createdAt: new Date(),
|
|
215
|
+
updatedAt: new Date()
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
const res = await adapter.findMany({
|
|
219
|
+
model: 'user',
|
|
220
|
+
sortBy: {
|
|
221
|
+
field: 'name',
|
|
222
|
+
direction: 'asc'
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
expect(res[0].name).toBe('a');
|
|
226
|
+
const res2 = await adapter.findMany({
|
|
227
|
+
model: 'user',
|
|
228
|
+
sortBy: {
|
|
229
|
+
field: 'name',
|
|
230
|
+
direction: 'desc'
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
expect(res2[res2.length - 1].name).toBe('a');
|
|
234
|
+
});
|
|
235
|
+
test('should find many with limit', async ()=>{
|
|
236
|
+
const res = await adapter.findMany({
|
|
237
|
+
model: 'user',
|
|
238
|
+
limit: 1
|
|
239
|
+
});
|
|
240
|
+
expect(res.length).toBe(1);
|
|
241
|
+
});
|
|
242
|
+
test('should update with multiple where', async ()=>{
|
|
243
|
+
await adapter.updateMany({
|
|
244
|
+
model: 'user',
|
|
245
|
+
where: [
|
|
246
|
+
{
|
|
247
|
+
field: 'name',
|
|
248
|
+
value: user.name
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
field: 'email',
|
|
252
|
+
value: user.email
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
update: {
|
|
256
|
+
email: 'updated@email.com'
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
const updatedUser = await adapter.findOne({
|
|
260
|
+
model: 'user',
|
|
261
|
+
where: [
|
|
262
|
+
{
|
|
263
|
+
field: 'email',
|
|
264
|
+
value: 'updated@email.com'
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
});
|
|
268
|
+
expect(updatedUser).toMatchObject({
|
|
269
|
+
name: user.name,
|
|
270
|
+
email: 'updated@email.com'
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
test('delete model', async ()=>{
|
|
274
|
+
await adapter.delete({
|
|
275
|
+
model: 'user',
|
|
276
|
+
where: [
|
|
277
|
+
{
|
|
278
|
+
field: 'id',
|
|
279
|
+
value: user.id
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
});
|
|
283
|
+
const findRes = await adapter.findOne({
|
|
284
|
+
model: 'user',
|
|
285
|
+
where: [
|
|
286
|
+
{
|
|
287
|
+
field: 'id',
|
|
288
|
+
value: user.id
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
});
|
|
292
|
+
expect(findRes).toBeNull();
|
|
293
|
+
});
|
|
294
|
+
test('should delete many', async ()=>{
|
|
295
|
+
for (const id of [
|
|
296
|
+
'to-be-delete1',
|
|
297
|
+
'to-be-delete2',
|
|
298
|
+
'to-be-delete3'
|
|
299
|
+
]){
|
|
300
|
+
await adapter.create({
|
|
301
|
+
model: 'user',
|
|
302
|
+
data: {
|
|
303
|
+
id,
|
|
304
|
+
name: 'to-be-deleted',
|
|
305
|
+
email: `email@test-${id}.com`,
|
|
306
|
+
emailVerified: true,
|
|
307
|
+
createdAt: new Date(),
|
|
308
|
+
updatedAt: new Date()
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
const findResFirst = await adapter.findMany({
|
|
313
|
+
model: 'user',
|
|
314
|
+
where: [
|
|
315
|
+
{
|
|
316
|
+
field: 'name',
|
|
317
|
+
value: 'to-be-deleted'
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
expect(findResFirst.length).toBe(3);
|
|
322
|
+
await adapter.deleteMany({
|
|
323
|
+
model: 'user',
|
|
324
|
+
where: [
|
|
325
|
+
{
|
|
326
|
+
field: 'name',
|
|
327
|
+
value: 'to-be-deleted'
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
});
|
|
331
|
+
const findRes = await adapter.findMany({
|
|
332
|
+
model: 'user',
|
|
333
|
+
where: [
|
|
334
|
+
{
|
|
335
|
+
field: 'name',
|
|
336
|
+
value: 'to-be-deleted'
|
|
337
|
+
}
|
|
338
|
+
]
|
|
339
|
+
});
|
|
340
|
+
expect(findRes.length).toBe(0);
|
|
341
|
+
});
|
|
342
|
+
test("shouldn't throw on delete record not found", async ()=>{
|
|
343
|
+
await adapter.delete({
|
|
344
|
+
model: 'user',
|
|
345
|
+
where: [
|
|
346
|
+
{
|
|
347
|
+
field: 'id',
|
|
348
|
+
value: '5'
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
test("shouldn't throw on record not found", async ()=>{
|
|
354
|
+
const res = await adapter.findOne({
|
|
355
|
+
model: 'user',
|
|
356
|
+
where: [
|
|
357
|
+
{
|
|
358
|
+
field: 'id',
|
|
359
|
+
value: '5'
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
});
|
|
363
|
+
expect(res).toBeNull();
|
|
364
|
+
});
|
|
365
|
+
test('should find many with contains operator', async ()=>{
|
|
366
|
+
const res = await adapter.findMany({
|
|
367
|
+
model: 'user',
|
|
368
|
+
where: [
|
|
369
|
+
{
|
|
370
|
+
field: 'name',
|
|
371
|
+
operator: 'contains',
|
|
372
|
+
value: 'user2'
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
});
|
|
376
|
+
expect(res.length).toBe(1);
|
|
377
|
+
});
|
|
378
|
+
test('should search users with startsWith', async ()=>{
|
|
379
|
+
const res = await adapter.findMany({
|
|
380
|
+
model: 'user',
|
|
381
|
+
where: [
|
|
382
|
+
{
|
|
383
|
+
field: 'name',
|
|
384
|
+
operator: 'starts_with',
|
|
385
|
+
value: 'us'
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
});
|
|
389
|
+
expect(res.length).toBe(3);
|
|
390
|
+
});
|
|
391
|
+
test('should search users with endsWith', async ()=>{
|
|
392
|
+
const res = await adapter.findMany({
|
|
393
|
+
model: 'user',
|
|
394
|
+
where: [
|
|
395
|
+
{
|
|
396
|
+
field: 'name',
|
|
397
|
+
operator: 'ends_with',
|
|
398
|
+
value: 'er2'
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
});
|
|
402
|
+
expect(res.length).toBe(1);
|
|
403
|
+
});
|
|
404
|
+
test.skipIf(opts.skipGenerateIdTest)('should prefer generateId if provided', async ()=>{
|
|
405
|
+
const customAdapter = await opts.getAdapter({
|
|
406
|
+
advanced: {
|
|
407
|
+
generateId: ()=>'mocked-id'
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
const res = await customAdapter.create({
|
|
411
|
+
model: 'user',
|
|
412
|
+
data: {
|
|
413
|
+
id: '1',
|
|
414
|
+
name: 'user4',
|
|
415
|
+
email: 'user4@email.com',
|
|
416
|
+
emailVerified: true,
|
|
417
|
+
createdAt: new Date(),
|
|
418
|
+
updatedAt: new Date()
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
expect(res.id).toBe('mocked-id');
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
//# sourceMappingURL=better-auth-adapter-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/test/better-auth-adapter-test.ts"],"sourcesContent":["import { expect, test } from 'vitest'\nimport type { Adapter, BetterAuthOptions } from 'better-auth'\nimport { User } from 'better-auth'\nimport { generateId } from 'better-auth'\n\ninterface AdapterTestOptions {\n getAdapter: (customOptions?: Omit<BetterAuthOptions, 'database'>) => Promise<Adapter>\n skipGenerateIdTest?: boolean\n}\n\nexport async function runAdapterTest(opts: AdapterTestOptions) {\n const adapter = await opts.getAdapter()\n const user = {\n id: '1',\n name: 'user',\n email: 'user@email.com',\n emailVerified: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n }\n\n test('create model', async () => {\n const res = await adapter.create({\n model: 'user',\n data: user,\n })\n expect({\n name: res.name,\n email: res.email,\n }).toEqual({\n name: user.name,\n email: user.email,\n })\n user.id = res.id\n })\n\n test('find model', async () => {\n const res = await adapter.findOne<User>({\n model: 'user',\n where: [\n {\n field: 'id',\n value: user.id,\n },\n ],\n })\n expect({\n name: res?.name,\n email: res?.email,\n }).toEqual({\n name: user.name,\n email: user.email,\n })\n })\n\n test('find model without id', async () => {\n const res = await adapter.findOne<User>({\n model: 'user',\n where: [\n {\n field: 'email',\n value: user.email,\n },\n ],\n })\n expect({\n name: res?.name,\n email: res?.email,\n }).toEqual({\n name: user.name,\n email: user.email,\n })\n })\n\n test('find model with select', async () => {\n const res = await adapter.findOne({\n model: 'user',\n where: [\n {\n field: 'id',\n value: user.id,\n },\n ],\n select: ['email'],\n })\n expect(res).toEqual({ id: user.id, email: user.email })\n })\n\n test('update model', async () => {\n const newEmail = 'updated@email.com'\n\n const res = await adapter.update<User>({\n model: 'user',\n where: [\n {\n field: 'id',\n value: user.id,\n },\n ],\n update: {\n email: newEmail,\n },\n })\n expect(res).toMatchObject({\n email: newEmail,\n name: user.name,\n })\n })\n\n test('should find many', async () => {\n const res = await adapter.findMany({\n model: 'user',\n })\n expect(res.length).toBe(1)\n })\n\n test('should find many with where', async () => {\n const user = await adapter.create<User>({\n model: 'user',\n data: {\n id: '2',\n name: 'user2',\n email: 'test@email.com',\n emailVerified: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n })\n const res = await adapter.findMany({\n model: 'user',\n where: [\n {\n field: 'id',\n value: user.id,\n },\n ],\n })\n expect(res.length).toBe(1)\n })\n\n test('should find many with operators', async () => {\n const newUser = await adapter.create<User>({\n model: 'user',\n data: {\n id: '3',\n name: 'user',\n email: 'test-email2@email.com',\n emailVerified: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n })\n const res = await adapter.findMany({\n model: 'user',\n where: [\n {\n field: 'id',\n operator: 'in',\n value: [user.id, newUser.id],\n },\n ],\n })\n expect(res.length).toBe(2)\n })\n\n test('should work with reference fields', async () => {\n let token: string | null = null\n const user = await adapter.create<{ id: string } & Record<string, any>>({\n model: 'user',\n data: {\n id: '4',\n name: 'user',\n email: 'my-email@email.com',\n emailVerified: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n })\n const session = await adapter.create({\n model: 'session',\n data: {\n id: '1',\n token: generateId(),\n createdAt: new Date(),\n updatedAt: new Date(),\n userId: user.id,\n expiresAt: new Date(),\n },\n })\n token = session.token\n const res = await adapter.findOne({\n model: 'session',\n where: [\n {\n field: 'userId',\n value: user.id,\n },\n ],\n })\n const resToken = await adapter.findOne({\n model: 'session',\n where: [\n {\n field: 'token',\n value: token,\n },\n ],\n })\n expect(res).toMatchObject({\n userId: user.id,\n })\n expect(resToken).toMatchObject({\n userId: user.id,\n })\n })\n\n test('should find many with sortBy', async () => {\n await adapter.create({\n model: 'user',\n data: {\n id: '5',\n name: 'a',\n email: 'a@email.com',\n emailVerified: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n })\n const res = await adapter.findMany<User>({\n model: 'user',\n sortBy: {\n field: 'name',\n direction: 'asc',\n },\n })\n expect(res[0].name).toBe('a')\n\n const res2 = await adapter.findMany<User>({\n model: 'user',\n sortBy: {\n field: 'name',\n direction: 'desc',\n },\n })\n\n expect(res2[res2.length - 1].name).toBe('a')\n })\n\n test('should find many with limit', async () => {\n const res = await adapter.findMany({\n model: 'user',\n limit: 1,\n })\n expect(res.length).toBe(1)\n })\n\n test('should update with multiple where', async () => {\n await adapter.updateMany({\n model: 'user',\n where: [\n {\n field: 'name',\n value: user.name,\n },\n {\n field: 'email',\n value: user.email,\n },\n ],\n update: {\n email: 'updated@email.com',\n },\n })\n const updatedUser = await adapter.findOne<User>({\n model: 'user',\n where: [\n {\n field: 'email',\n value: 'updated@email.com',\n },\n ],\n })\n expect(updatedUser).toMatchObject({\n name: user.name,\n email: 'updated@email.com',\n })\n })\n\n test('delete model', async () => {\n await adapter.delete({\n model: 'user',\n where: [\n {\n field: 'id',\n value: user.id,\n },\n ],\n })\n const findRes = await adapter.findOne({\n model: 'user',\n where: [\n {\n field: 'id',\n value: user.id,\n },\n ],\n })\n expect(findRes).toBeNull()\n })\n\n test('should delete many', async () => {\n for (const id of ['to-be-delete1', 'to-be-delete2', 'to-be-delete3']) {\n await adapter.create({\n model: 'user',\n data: {\n id,\n name: 'to-be-deleted',\n email: `email@test-${id}.com`,\n emailVerified: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n })\n }\n const findResFirst = await adapter.findMany({\n model: 'user',\n where: [\n {\n field: 'name',\n value: 'to-be-deleted',\n },\n ],\n })\n expect(findResFirst.length).toBe(3)\n await adapter.deleteMany({\n model: 'user',\n where: [\n {\n field: 'name',\n value: 'to-be-deleted',\n },\n ],\n })\n const findRes = await adapter.findMany({\n model: 'user',\n where: [\n {\n field: 'name',\n value: 'to-be-deleted',\n },\n ],\n })\n expect(findRes.length).toBe(0)\n })\n\n test(\"shouldn't throw on delete record not found\", async () => {\n await adapter.delete({\n model: 'user',\n where: [\n {\n field: 'id',\n value: '5',\n },\n ],\n })\n })\n\n test(\"shouldn't throw on record not found\", async () => {\n const res = await adapter.findOne({\n model: 'user',\n where: [\n {\n field: 'id',\n value: '5',\n },\n ],\n })\n expect(res).toBeNull()\n })\n\n test('should find many with contains operator', async () => {\n const res = await adapter.findMany({\n model: 'user',\n where: [\n {\n field: 'name',\n operator: 'contains',\n value: 'user2',\n },\n ],\n })\n expect(res.length).toBe(1)\n })\n\n test('should search users with startsWith', async () => {\n const res = await adapter.findMany({\n model: 'user',\n where: [\n {\n field: 'name',\n operator: 'starts_with',\n value: 'us',\n },\n ],\n })\n expect(res.length).toBe(3)\n })\n\n test('should search users with endsWith', async () => {\n const res = await adapter.findMany({\n model: 'user',\n where: [\n {\n field: 'name',\n operator: 'ends_with',\n value: 'er2',\n },\n ],\n })\n expect(res.length).toBe(1)\n })\n\n test.skipIf(opts.skipGenerateIdTest)('should prefer generateId if provided', async () => {\n const customAdapter = await opts.getAdapter({\n advanced: {\n generateId: () => 'mocked-id',\n },\n })\n\n const res = await customAdapter.create({\n model: 'user',\n data: {\n id: '1',\n name: 'user4',\n email: 'user4@email.com',\n emailVerified: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n })\n\n expect(res.id).toBe('mocked-id')\n })\n}\n"],"names":["expect","test","generateId","runAdapterTest","opts","adapter","getAdapter","user","id","name","email","emailVerified","createdAt","Date","updatedAt","res","create","model","data","toEqual","findOne","where","field","value","select","newEmail","update","toMatchObject","findMany","length","toBe","newUser","operator","token","session","userId","expiresAt","resToken","sortBy","direction","res2","limit","updateMany","updatedUser","delete","findRes","toBeNull","findResFirst","deleteMany","skipIf","skipGenerateIdTest","customAdapter","advanced"],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,SAAQ;AAGrC,SAASC,UAAU,QAAQ,cAAa;AAOxC,OAAO,eAAeC,eAAeC,IAAwB;IAC3D,MAAMC,UAAU,MAAMD,KAAKE,UAAU;IACrC,MAAMC,OAAO;QACXC,IAAI;QACJC,MAAM;QACNC,OAAO;QACPC,eAAe;QACfC,WAAW,IAAIC;QACfC,WAAW,IAAID;IACjB;IAEAZ,KAAK,gBAAgB;QACnB,MAAMc,MAAM,MAAMV,Q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