@coursebuilder/adapter-drizzle 0.1.2 → 0.1.3

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.
Files changed (100) hide show
  1. package/dist/{chunk-ISURSRBK.js → chunk-3LWFRGZT.js} +519 -313
  2. package/dist/{chunk-RVYJDDZD.js → chunk-NXFHRDLS.js} +2 -2
  3. package/dist/{chunk-44VDBYFU.js → chunk-QK6CINAJ.js} +3 -3
  4. package/dist/{chunk-MYRB6GLJ.js → chunk-ULABK6XG.js} +2 -2
  5. package/dist/{chunk-DHYYRN35.js → chunk-XSXWLOIN.js} +4624 -448
  6. package/dist/{chunk-QZOBGJSV.js → chunk-XXZQBN6S.js} +2 -2
  7. package/dist/index.d.ts +0 -2
  8. package/dist/index.js +11 -27
  9. package/dist/lib/mysql/index.cjs +880 -721
  10. package/dist/lib/mysql/index.cjs.map +1 -1
  11. package/dist/lib/mysql/index.d.ts +212 -10
  12. package/dist/lib/mysql/index.js +11 -14
  13. package/dist/lib/mysql/schemas/auth/accounts.cjs +73 -57
  14. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  15. package/dist/lib/mysql/schemas/auth/accounts.js +5 -4
  16. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +64 -48
  17. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  18. package/dist/lib/mysql/schemas/auth/role-permissions.js +6 -5
  19. package/dist/lib/mysql/schemas/auth/roles.cjs +64 -48
  20. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  21. package/dist/lib/mysql/schemas/auth/roles.js +5 -4
  22. package/dist/lib/mysql/schemas/auth/sessions.cjs +64 -48
  23. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  24. package/dist/lib/mysql/schemas/auth/sessions.js +6 -5
  25. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +65 -49
  26. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  27. package/dist/lib/mysql/schemas/auth/user-permissions.js +5 -4
  28. package/dist/lib/mysql/schemas/auth/user-roles.cjs +67 -51
  29. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  30. package/dist/lib/mysql/schemas/auth/user-roles.js +5 -4
  31. package/dist/lib/mysql/schemas/auth/users.cjs +170 -154
  32. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  33. package/dist/lib/mysql/schemas/auth/users.js +5 -4
  34. package/dist/lib/mysql/schemas/commerce/coupon.cjs +1 -1
  35. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  36. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +4 -4
  37. package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
  38. package/dist/lib/mysql/schemas/commerce/price.cjs +189 -11
  39. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/commerce/price.d.ts +6 -1
  41. package/dist/lib/mysql/schemas/commerce/price.js +14 -3
  42. package/dist/lib/mysql/schemas/commerce/product.cjs +227 -9
  43. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/commerce/product.d.ts +8 -2
  45. package/dist/lib/mysql/schemas/commerce/product.js +12 -1
  46. package/dist/lib/mysql/schemas/commerce/purchase.cjs +140 -122
  47. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  48. package/dist/lib/mysql/schemas/commerce/purchase.js +5 -4
  49. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +107 -24
  50. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  51. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -2
  52. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +84 -68
  53. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  54. package/dist/lib/mysql/schemas/communication/communication-preferences.js +5 -4
  55. package/dist/lib/mysql/schemas/content/content-contributions.cjs +92 -76
  56. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  57. package/dist/lib/mysql/schemas/content/content-contributions.js +5 -4
  58. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +243 -0
  59. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -0
  60. package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +101 -0
  61. package/dist/lib/mysql/schemas/content/content-resource-product.js +19 -0
  62. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +67 -51
  63. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  64. package/dist/lib/mysql/schemas/content/content-resource-resource.js +5 -4
  65. package/dist/lib/mysql/schemas/content/content-resource.cjs +116 -62
  66. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  67. package/dist/lib/mysql/schemas/content/content-resource.d.ts +1 -0
  68. package/dist/lib/mysql/schemas/content/content-resource.js +5 -4
  69. package/dist/lib/utils.cjs.map +1 -1
  70. package/dist/lib/utils.d.ts +3 -7
  71. package/dist/lib/utils.js +12 -3
  72. package/dist/lib/utils.js.map +1 -1
  73. package/package.json +2 -2
  74. package/src/index.ts +0 -8
  75. package/src/lib/mysql/index.ts +154 -23
  76. package/src/lib/mysql/schemas/auth/user-roles.ts +2 -2
  77. package/src/lib/mysql/schemas/commerce/coupon.ts +2 -2
  78. package/src/lib/mysql/schemas/commerce/price.ts +22 -1
  79. package/src/lib/mysql/schemas/commerce/product.ts +26 -2
  80. package/src/lib/mysql/schemas/content/content-resource-product.ts +62 -0
  81. package/src/lib/mysql/schemas/content/content-resource.ts +5 -0
  82. package/src/lib/utils.ts +1 -9
  83. package/dist/chunk-7LAAAEVE.js +0 -379
  84. package/dist/chunk-AFQGYW7Z.js +0 -45
  85. package/dist/chunk-CPE4P26C.js +0 -42
  86. package/dist/chunk-GFUUJRX7.js +0 -18
  87. package/dist/chunk-O2KKII62.js +0 -381
  88. package/dist/chunk-Y34AIPU7.js +0 -4137
  89. package/dist/lib/pg.cjs +0 -4527
  90. package/dist/lib/pg.cjs.map +0 -1
  91. package/dist/lib/pg.d.ts +0 -496
  92. package/dist/lib/pg.js +0 -11
  93. package/dist/lib/sqlite.cjs +0 -4536
  94. package/dist/lib/sqlite.cjs.map +0 -1
  95. package/dist/lib/sqlite.d.ts +0 -496
  96. package/dist/lib/sqlite.js +0 -12
  97. package/dist/lib/sqlite.js.map +0 -1
  98. package/src/lib/pg.ts +0 -579
  99. package/src/lib/sqlite.ts +0 -562
  100. /package/dist/lib/{pg.js.map → mysql/schemas/content/content-resource-product.js.map} +0 -0
package/src/lib/sqlite.ts DELETED
@@ -1,562 +0,0 @@
1
- import type { AdapterAccount } from '@auth/core/adapters'
2
- import { and, asc, eq, sql } from 'drizzle-orm'
3
- import {
4
- BaseSQLiteDatabase,
5
- sqliteTable as defaultSqliteTableFn,
6
- integer,
7
- primaryKey,
8
- SQLiteTableFn,
9
- text,
10
- } from 'drizzle-orm/sqlite-core'
11
-
12
- import { type CourseBuilderAdapter } from '@coursebuilder/core/adapters'
13
- import {
14
- Coupon,
15
- MerchantCoupon,
16
- MerchantCustomer,
17
- MerchantProduct,
18
- Price,
19
- Product,
20
- Purchase,
21
- PurchaseUserTransfer,
22
- PurchaseUserTransferState,
23
- ResourceProgress,
24
- UpgradableProduct,
25
- User,
26
- } from '@coursebuilder/core/schemas'
27
- import { ContentResourceSchema } from '@coursebuilder/core/schemas/content-resource-schema'
28
-
29
- import { stripUndefined } from './utils.js'
30
-
31
- export function createTables(sqliteTable: SQLiteTableFn) {
32
- const users = sqliteTable('user', {
33
- id: text('id').notNull().primaryKey(),
34
- name: text('name'),
35
- role: text('role', { enum: ['user', 'admin'] }).default('user'),
36
- email: text('email').notNull(),
37
- emailVerified: integer('emailVerified', { mode: 'timestamp_ms' }),
38
- image: text('image'),
39
- })
40
-
41
- const accounts = sqliteTable(
42
- 'account',
43
- {
44
- userId: text('userId')
45
- .notNull()
46
- .references(() => users.id, { onDelete: 'cascade' }),
47
- type: text('type').$type<AdapterAccount['type']>().notNull(),
48
- provider: text('provider').notNull(),
49
- providerAccountId: text('providerAccountId').notNull(),
50
- refresh_token: text('refresh_token'),
51
- access_token: text('access_token'),
52
- expires_at: integer('expires_at'),
53
- token_type: text('token_type'),
54
- scope: text('scope'),
55
- id_token: text('id_token'),
56
- session_state: text('session_state'),
57
- },
58
- (account) => ({
59
- pk: primaryKey({
60
- columns: [account.provider, account.providerAccountId],
61
- }),
62
- }),
63
- )
64
-
65
- const sessions = sqliteTable('session', {
66
- sessionToken: text('sessionToken').notNull().primaryKey(),
67
- userId: text('userId')
68
- .notNull()
69
- .references(() => users.id, { onDelete: 'cascade' }),
70
- expires: integer('expires', { mode: 'timestamp_ms' }).notNull(),
71
- })
72
-
73
- const verificationTokens = sqliteTable(
74
- 'verificationToken',
75
- {
76
- identifier: text('identifier').notNull(),
77
- token: text('token').notNull(),
78
- expires: integer('expires', { mode: 'timestamp_ms' }).notNull(),
79
- },
80
- (vt) => ({
81
- pk: primaryKey({ columns: [vt.identifier, vt.token] }),
82
- }),
83
- )
84
-
85
- const contentResource = sqliteTable('contentResource', {
86
- id: text('id', { length: 255 }).notNull().primaryKey(),
87
- type: text('type', { length: 255 }).notNull(),
88
- createdById: text('createdById', { length: 255 }).notNull(),
89
- fields: text('metadata', { mode: 'json' })
90
- .$type<Record<string, any>>()
91
- .default({}),
92
- createdAt: integer('createdAt', {
93
- mode: 'timestamp_ms',
94
- }).default(sql`CURRENT_TIME`),
95
- updatedAt: integer('updatedAt', {
96
- mode: 'timestamp_ms',
97
- }).default(sql`CURRENT_TIME`),
98
- deletedAt: integer('deletedAt', {
99
- mode: 'timestamp_ms',
100
- }),
101
- })
102
-
103
- const contentResourceResource = sqliteTable(
104
- 'contentResourceResource',
105
- {
106
- resourceOfId: text('resourceOfId', { length: 255 }).notNull(),
107
- resourceId: text('resourceId', { length: 255 }).notNull(),
108
- position: integer('position').notNull().default(0),
109
- metadata: text('metadata', { mode: 'json' })
110
- .$type<Record<string, any>>()
111
- .default({}),
112
- createdAt: integer('createdAt', {
113
- mode: 'timestamp_ms',
114
- }).default(sql`CURRENT_TIME`),
115
- updatedAt: integer('updatedAt', {
116
- mode: 'timestamp_ms',
117
- }).default(sql`CURRENT_TIME`),
118
- deletedAt: integer('deletedAt', {
119
- mode: 'timestamp_ms',
120
- }),
121
- },
122
- (crr) => ({
123
- pk: primaryKey({ columns: [crr.resourceOfId, crr.resourceId] }),
124
- }),
125
- )
126
-
127
- return {
128
- users,
129
- accounts,
130
- sessions,
131
- verificationTokens,
132
- contentResource,
133
- contentResourceResource,
134
- }
135
- }
136
-
137
- export type DefaultSchema = ReturnType<typeof createTables>
138
-
139
- export function SQLiteDrizzleAdapter(
140
- client: InstanceType<typeof BaseSQLiteDatabase>,
141
- tableFn = defaultSqliteTableFn,
142
- ): CourseBuilderAdapter {
143
- const {
144
- users,
145
- accounts,
146
- sessions,
147
- verificationTokens,
148
- contentResource,
149
- contentResourceResource,
150
- } = createTables(tableFn)
151
-
152
- return {
153
- client,
154
- availableUpgradesForProduct(
155
- purchases: any,
156
- productId: string,
157
- ): Promise<
158
- {
159
- upgradableTo: { id: string; name: string }
160
- upgradableFrom: { id: string; name: string }
161
- }[]
162
- > {
163
- return Promise.resolve([])
164
- },
165
- clearLessonProgressForUser(options: {
166
- userId: string
167
- lessons: { id: string; slug: string }[]
168
- }): Promise<void> {
169
- return Promise.resolve(undefined)
170
- },
171
- completeLessonProgressForUser(options: {
172
- userId: string
173
- lessonId?: string
174
- }): Promise<ResourceProgress | null> {
175
- return Promise.resolve(null)
176
- },
177
- couponForIdOrCode(options: {
178
- code?: string
179
- couponId?: string
180
- }): Promise<(Coupon & { merchantCoupon: MerchantCoupon }) | null> {
181
- return Promise.resolve(null)
182
- },
183
- createMerchantChargeAndPurchase(options: {
184
- userId: string
185
- productId: string
186
- stripeChargeId: string
187
- stripeCouponId?: string
188
- merchantAccountId: string
189
- merchantProductId: string
190
- merchantCustomerId: string
191
- stripeChargeAmount: number
192
- quantity?: number
193
- bulk?: boolean
194
- checkoutSessionId: string
195
- appliedPPPStripeCouponId: string | undefined
196
- upgradedFromPurchaseId: string | undefined
197
- usedCouponId: string | undefined
198
- country?: string
199
- }): Promise<Purchase> {
200
- throw new Error('Method not implemented.')
201
- },
202
- findOrCreateMerchantCustomer(options: {
203
- user: User
204
- identifier: string
205
- merchantAccountId: string
206
- }): Promise<MerchantCustomer | null> {
207
- return Promise.resolve(null)
208
- },
209
- findOrCreateUser(
210
- email: string,
211
- name?: string | null,
212
- ): Promise<{
213
- user: User
214
- isNewUser: boolean
215
- }> {
216
- throw new Error('Method not implemented.')
217
- },
218
- getCoupon(couponIdOrCode: string): Promise<Coupon | null> {
219
- return Promise.resolve(null)
220
- },
221
- getCouponWithBulkPurchases(couponId: string): Promise<
222
- | (Coupon & {
223
- bulkCouponPurchases: { bulkCouponId: string }[]
224
- })
225
- | null
226
- > {
227
- return Promise.resolve(null)
228
- },
229
- getDefaultCoupon(productIds?: string[]): Promise<{
230
- defaultMerchantCoupon: MerchantCoupon
231
- defaultCoupon: Coupon
232
- } | null> {
233
- return Promise.resolve(null)
234
- },
235
- getLessonProgressCountsByDate(): Promise<
236
- {
237
- count: number
238
- completedAt: string
239
- }[]
240
- > {
241
- return Promise.resolve([])
242
- },
243
- getLessonProgressForUser(userId: string): Promise<ResourceProgress[]> {
244
- return Promise.resolve([])
245
- },
246
- getLessonProgresses(): Promise<ResourceProgress[]> {
247
- return Promise.resolve([])
248
- },
249
- getMerchantCharge(merchantChargeId: string): Promise<{
250
- id: string
251
- identifier: string
252
- merchantProductId: string
253
- } | null> {
254
- return Promise.resolve(null)
255
- },
256
- getMerchantCoupon(
257
- merchantCouponId: string,
258
- ): Promise<MerchantCoupon | null> {
259
- return Promise.resolve(null)
260
- },
261
- getMerchantProduct(
262
- stripeProductId: string,
263
- ): Promise<MerchantProduct | null> {
264
- return Promise.resolve(null)
265
- },
266
- getPrice(productId: string): Promise<Price | null> {
267
- return Promise.resolve(null)
268
- },
269
- getProduct(productId: string): Promise<Product | null> {
270
- return Promise.resolve(null)
271
- },
272
- getPurchase(purchaseId: string): Promise<Purchase | null> {
273
- return Promise.resolve(null)
274
- },
275
- getPurchaseDetails(
276
- purchaseId: string,
277
- userId: string,
278
- ): Promise<{
279
- purchase?: Purchase
280
- existingPurchase?: Purchase
281
- availableUpgrades: UpgradableProduct[]
282
- }> {
283
- return Promise.resolve({ availableUpgrades: [] })
284
- },
285
- getPurchaseForStripeCharge(
286
- stripeChargeId: string,
287
- ): Promise<Purchase | null> {
288
- return Promise.resolve(null)
289
- },
290
- getPurchaseUserTransferById(options: { id: string }): Promise<
291
- | (PurchaseUserTransfer & {
292
- sourceUser: User
293
- targetUser: User | null
294
- purchase: Purchase
295
- })
296
- | null
297
- > {
298
- return Promise.resolve(null)
299
- },
300
- getPurchaseWithUser(purchaseId: string): Promise<
301
- | (Purchase & {
302
- user: User
303
- })
304
- | null
305
- > {
306
- return Promise.resolve(null)
307
- },
308
- getPurchasesForUser(userId?: string): Promise<
309
- (Purchase & {
310
- bulkCoupon: { id: string; maxUses: number; usedCount: number } | null
311
- product: { id: string; name: string }
312
- })[]
313
- > {
314
- return Promise.resolve([])
315
- },
316
- getUserById(userId: string): Promise<User | null> {
317
- return Promise.resolve(null)
318
- },
319
- pricesOfPurchasesTowardOneBundle(options: {
320
- userId: string | undefined
321
- bundleId: string
322
- }): Promise<Price[]> {
323
- return Promise.resolve([])
324
- },
325
- async createPurchase(options): Promise<Purchase> {
326
- throw new Error('Method not implemented.')
327
- },
328
- toggleLessonProgressForUser(options: {
329
- userId: string
330
- lessonId?: string
331
- lessonSlug?: string
332
- }): Promise<ResourceProgress | null> {
333
- return Promise.resolve(null)
334
- },
335
- transferPurchasesToNewUser(options: {
336
- merchantCustomerId: string
337
- userId: string
338
- }): Promise<unknown> {
339
- return Promise.resolve(undefined)
340
- },
341
- updatePurchaseStatusForCharge(
342
- chargeId: string,
343
- status: 'Valid' | 'Refunded' | 'Disputed' | 'Banned' | 'Restricted',
344
- ): Promise<Purchase | undefined> {
345
- return Promise.resolve(undefined)
346
- },
347
- updatePurchaseUserTransferTransferState(options: {
348
- id: string
349
- transferState: PurchaseUserTransferState
350
- }): Promise<PurchaseUserTransfer | null> {
351
- return Promise.resolve(null)
352
- },
353
- async addResourceToResource(options) {
354
- return null
355
- },
356
- async updateContentResourceFields(options) {
357
- return null
358
- },
359
- async getVideoResource(id) {
360
- // TODO Implement
361
- return null
362
- },
363
- async createContentResource(data) {
364
- const id = data.id || crypto.randomUUID()
365
-
366
- await client.insert(contentResource).values({ ...data, id })
367
-
368
- const resource = await client.query.contentResource.findFirst({
369
- where: eq(contentResource.id, id),
370
- with: {
371
- resources: {
372
- with: {
373
- resource: {
374
- with: {
375
- resources: {
376
- with: {
377
- resource: true,
378
- },
379
- orderBy: asc(contentResourceResource.position),
380
- },
381
- },
382
- },
383
- },
384
- orderBy: asc(contentResourceResource.position),
385
- },
386
- },
387
- })
388
-
389
- const parsedResource = ContentResourceSchema.safeParse(resource)
390
-
391
- if (!parsedResource.success) {
392
- console.error('Error parsing resource', resource)
393
- throw new Error('Error parsing resource')
394
- }
395
-
396
- return parsedResource.data
397
- },
398
- async getContentResource(data) {
399
- const resource = await client.query.contentResource.findFirst({
400
- where: eq(contentResource.id, data),
401
- with: {
402
- resources: {
403
- with: {
404
- resource: {
405
- with: {
406
- resources: {
407
- with: {
408
- resource: true,
409
- },
410
- orderBy: asc(contentResourceResource.position),
411
- },
412
- },
413
- },
414
- },
415
- orderBy: asc(contentResourceResource.position),
416
- },
417
- },
418
- })
419
-
420
- const parsedResource = ContentResourceSchema.safeParse(resource)
421
-
422
- if (!parsedResource.success) {
423
- console.error('Error parsing resource', resource)
424
- return null
425
- }
426
-
427
- return parsedResource.data
428
- },
429
- async createUser(data) {
430
- return client
431
- .insert(users)
432
- .values({ ...data, id: crypto.randomUUID() })
433
- .returning()
434
- .get()
435
- },
436
- async getUser(data) {
437
- const result = await client
438
- .select()
439
- .from(users)
440
- .where(eq(users.id, data))
441
- .get()
442
- return result ?? null
443
- },
444
- async getUserByEmail(data) {
445
- const result = await client
446
- .select()
447
- .from(users)
448
- .where(eq(users.email, data))
449
- .get()
450
- return result ?? null
451
- },
452
- createSession(data) {
453
- return client.insert(sessions).values(data).returning().get()
454
- },
455
- async getSessionAndUser(data) {
456
- const result = await client
457
- .select({ session: sessions, user: users })
458
- .from(sessions)
459
- .where(eq(sessions.sessionToken, data))
460
- .innerJoin(users, eq(users.id, sessions.userId))
461
- .get()
462
- return result ?? null
463
- },
464
- async updateUser(data) {
465
- if (!data.id) {
466
- throw new Error('No user id.')
467
- }
468
-
469
- const result = await client
470
- .update(users)
471
- .set(data)
472
- .where(eq(users.id, data.id))
473
- .returning()
474
- .get()
475
- return result ?? null
476
- },
477
- async updateSession(data) {
478
- const result = await client
479
- .update(sessions)
480
- .set(data)
481
- .where(eq(sessions.sessionToken, data.sessionToken))
482
- .returning()
483
- .get()
484
- return result ?? null
485
- },
486
- async linkAccount(rawAccount) {
487
- return stripUndefined(
488
- await client.insert(accounts).values(rawAccount).returning().get(),
489
- )
490
- },
491
- async getUserByAccount(account) {
492
- const results = await client
493
- .select()
494
- .from(accounts)
495
- .leftJoin(users, eq(users.id, accounts.userId))
496
- .where(
497
- and(
498
- eq(accounts.provider, account.provider),
499
- eq(accounts.providerAccountId, account.providerAccountId),
500
- ),
501
- )
502
- .get()
503
-
504
- if (!results) {
505
- return null
506
- }
507
- return Promise.resolve(results).then((results) => results.user)
508
- },
509
- async deleteSession(sessionToken) {
510
- const result = await client
511
- .delete(sessions)
512
- .where(eq(sessions.sessionToken, sessionToken))
513
- .returning()
514
- .get()
515
- return result ?? null
516
- },
517
- async createVerificationToken(token) {
518
- const result = await client
519
- .insert(verificationTokens)
520
- .values(token)
521
- .returning()
522
- .get()
523
- return result ?? null
524
- },
525
- async useVerificationToken(token) {
526
- try {
527
- const result = await client
528
- .delete(verificationTokens)
529
- .where(
530
- and(
531
- eq(verificationTokens.identifier, token.identifier),
532
- eq(verificationTokens.token, token.token),
533
- ),
534
- )
535
- .returning()
536
- .get()
537
- return result ?? null
538
- } catch (err) {
539
- throw new Error('No verification token found.')
540
- }
541
- },
542
- async deleteUser(id) {
543
- const result = await client
544
- .delete(users)
545
- .where(eq(users.id, id))
546
- .returning()
547
- .get()
548
- return result ?? null
549
- },
550
- async unlinkAccount(account) {
551
- await client
552
- .delete(accounts)
553
- .where(
554
- and(
555
- eq(accounts.providerAccountId, account.providerAccountId),
556
- eq(accounts.provider, account.provider),
557
- ),
558
- )
559
- .run()
560
- },
561
- }
562
- }