@auth/drizzle-adapter 0.3.0 → 0.3.2
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/index.d.ts.map +1 -1
- package/index.js +8 -6
- package/lib/mysql.d.ts +225 -0
- package/lib/mysql.d.ts.map +1 -0
- package/lib/mysql.js +189 -0
- package/lib/pg.d.ts +225 -0
- package/lib/pg.d.ts.map +1 -0
- package/lib/pg.js +180 -0
- package/lib/sqlite.d.ts +225 -0
- package/lib/sqlite.d.ts.map +1 -0
- package/lib/sqlite.js +154 -0
- package/lib/utils.d.ts +21 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +1 -0
- package/package.json +3 -3
- package/src/index.ts +11 -19
- package/src/lib/mysql.ts +3 -6
- package/src/lib/pg.ts +2 -2
- package/src/lib/sqlite.ts +1 -1
- package/src/lib/utils.ts +0 -14
package/src/lib/mysql.ts
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
primaryKey,
|
|
7
7
|
varchar,
|
|
8
8
|
MySqlTableFn,
|
|
9
|
+
MySqlDatabase,
|
|
9
10
|
} from "drizzle-orm/mysql-core"
|
|
10
11
|
|
|
11
12
|
import type { Adapter, AdapterAccount } from "@auth/core/adapters"
|
|
12
|
-
import type { MySql2Database } from "drizzle-orm/mysql2"
|
|
13
13
|
|
|
14
14
|
export function createTables(mySqlTable: MySqlTableFn) {
|
|
15
15
|
const users = mySqlTable("user", {
|
|
@@ -77,7 +77,7 @@ export function createTables(mySqlTable: MySqlTableFn) {
|
|
|
77
77
|
export type DefaultSchema = ReturnType<typeof createTables>
|
|
78
78
|
|
|
79
79
|
export function mySqlDrizzleAdapter(
|
|
80
|
-
client:
|
|
80
|
+
client: InstanceType<typeof MySqlDatabase>,
|
|
81
81
|
tableFn = defaultMySqlTableFn
|
|
82
82
|
): Adapter {
|
|
83
83
|
const { users, accounts, sessions, verificationTokens } =
|
|
@@ -164,10 +164,7 @@ export function mySqlDrizzleAdapter(
|
|
|
164
164
|
.then((res) => res[0])
|
|
165
165
|
},
|
|
166
166
|
async linkAccount(rawAccount) {
|
|
167
|
-
await client
|
|
168
|
-
.insert(accounts)
|
|
169
|
-
.values(rawAccount)
|
|
170
|
-
.then((res) => res[0])
|
|
167
|
+
await client.insert(accounts).values(rawAccount)
|
|
171
168
|
},
|
|
172
169
|
async getUserByAccount(account) {
|
|
173
170
|
const dbAccount =
|
package/src/lib/pg.ts
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
primaryKey,
|
|
7
7
|
integer,
|
|
8
8
|
PgTableFn,
|
|
9
|
+
PgDatabase,
|
|
9
10
|
} from "drizzle-orm/pg-core"
|
|
10
11
|
|
|
11
|
-
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"
|
|
12
12
|
import type { Adapter, AdapterAccount } from "@auth/core/adapters"
|
|
13
13
|
|
|
14
14
|
export function createTables(pgTable: PgTableFn) {
|
|
@@ -68,7 +68,7 @@ export function createTables(pgTable: PgTableFn) {
|
|
|
68
68
|
export type DefaultSchema = ReturnType<typeof createTables>
|
|
69
69
|
|
|
70
70
|
export function pgDrizzleAdapter(
|
|
71
|
-
client:
|
|
71
|
+
client: InstanceType<typeof PgDatabase>,
|
|
72
72
|
tableFn = defaultPgTableFn
|
|
73
73
|
): Adapter {
|
|
74
74
|
const { users, accounts, sessions, verificationTokens } =
|
package/src/lib/sqlite.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function createTables(sqliteTable: SQLiteTableFn) {
|
|
|
67
67
|
export type DefaultSchema = ReturnType<typeof createTables>
|
|
68
68
|
|
|
69
69
|
export function SQLiteDrizzleAdapter(
|
|
70
|
-
client:
|
|
70
|
+
client: InstanceType<typeof BaseSQLiteDatabase>,
|
|
71
71
|
tableFn = defaultSqliteTableFn
|
|
72
72
|
): Adapter {
|
|
73
73
|
const { users, accounts, sessions, verificationTokens } =
|
package/src/lib/utils.ts
CHANGED
|
@@ -39,17 +39,3 @@ export type TableFn<Flavor> = Flavor extends AnyMySqlDatabase
|
|
|
39
39
|
: Flavor extends AnySQLiteDatabase
|
|
40
40
|
? SQLiteTableFn
|
|
41
41
|
: AnySQLiteTable
|
|
42
|
-
|
|
43
|
-
export function isMySqlDatabase(
|
|
44
|
-
db: any
|
|
45
|
-
): db is MySqlDatabase<any, any, any, any> {
|
|
46
|
-
return db instanceof MySqlDatabase
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function isPgDatabase(db: any): db is PgDatabase<any, any, any> {
|
|
50
|
-
return db instanceof PgDatabase
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function isSQLiteDatabase(db: any): db is AnySQLiteDatabase {
|
|
54
|
-
return db instanceof BaseSQLiteDatabase
|
|
55
|
-
}
|