@auth/drizzle-adapter 0.3.11 → 0.3.13

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 CHANGED
@@ -88,7 +88,7 @@ import type { Adapter } from "@auth/core/adapters";
88
88
  * session_state: text("session_state"),
89
89
  * },
90
90
  * (account) => ({
91
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
91
+ * compoundKey: primaryKey({ columns: [account.provider, account.providerAccountId] }),
92
92
  * })
93
93
  * )
94
94
  *
@@ -108,7 +108,7 @@ import type { Adapter } from "@auth/core/adapters";
108
108
  * expires: timestamp("expires", { mode: "date" }).notNull(),
109
109
  * },
110
110
  * (vt) => ({
111
- * compoundKey: primaryKey(vt.identifier, vt.token),
111
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
112
112
  * })
113
113
  * )
114
114
  * ```
@@ -151,7 +151,9 @@ import type { Adapter } from "@auth/core/adapters";
151
151
  * session_state: varchar("session_state", { length: 255 }),
152
152
  * },
153
153
  * (account) => ({
154
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
154
+ * compoundKey: primaryKey({
155
+ columns: [account.provider, account.providerAccountId],
156
+ }),
155
157
  * })
156
158
  * )
157
159
  *
@@ -171,7 +173,7 @@ import type { Adapter } from "@auth/core/adapters";
171
173
  * expires: timestamp("expires", { mode: "date" }).notNull(),
172
174
  * },
173
175
  * (vt) => ({
174
- * compoundKey: primaryKey(vt.identifier, vt.token),
176
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
175
177
  * })
176
178
  * )
177
179
  * ```
@@ -208,7 +210,9 @@ import type { Adapter } from "@auth/core/adapters";
208
210
  * session_state: text("session_state"),
209
211
  * },
210
212
  * (account) => ({
211
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
213
+ * compoundKey: primaryKey({
214
+ columns: [account.provider, account.providerAccountId],
215
+ }),
212
216
  * })
213
217
  * )
214
218
  *
@@ -228,7 +232,7 @@ import type { Adapter } from "@auth/core/adapters";
228
232
  * expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
229
233
  * },
230
234
  * (vt) => ({
231
- * compoundKey: primaryKey(vt.identifier, vt.token),
235
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
232
236
  * })
233
237
  * )
234
238
  * ```
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAG1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+NI;AACJ,wBAAgB,cAAc,CAAC,SAAS,SAAS,gBAAgB,EAC/D,EAAE,EAAE,SAAS,EACb,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GACzB,OAAO,CAYT"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAG1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmOI;AACJ,wBAAgB,cAAc,CAAC,SAAS,SAAS,gBAAgB,EAC/D,EAAE,EAAE,SAAS,EACb,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GACzB,OAAO,CAYT"}
package/index.js CHANGED
@@ -93,7 +93,7 @@ import { is } from "drizzle-orm";
93
93
  * session_state: text("session_state"),
94
94
  * },
95
95
  * (account) => ({
96
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
96
+ * compoundKey: primaryKey({ columns: [account.provider, account.providerAccountId] }),
97
97
  * })
98
98
  * )
99
99
  *
@@ -113,7 +113,7 @@ import { is } from "drizzle-orm";
113
113
  * expires: timestamp("expires", { mode: "date" }).notNull(),
114
114
  * },
115
115
  * (vt) => ({
116
- * compoundKey: primaryKey(vt.identifier, vt.token),
116
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
117
117
  * })
118
118
  * )
119
119
  * ```
@@ -156,7 +156,9 @@ import { is } from "drizzle-orm";
156
156
  * session_state: varchar("session_state", { length: 255 }),
157
157
  * },
158
158
  * (account) => ({
159
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
159
+ * compoundKey: primaryKey({
160
+ columns: [account.provider, account.providerAccountId],
161
+ }),
160
162
  * })
161
163
  * )
162
164
  *
@@ -176,7 +178,7 @@ import { is } from "drizzle-orm";
176
178
  * expires: timestamp("expires", { mode: "date" }).notNull(),
177
179
  * },
178
180
  * (vt) => ({
179
- * compoundKey: primaryKey(vt.identifier, vt.token),
181
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
180
182
  * })
181
183
  * )
182
184
  * ```
@@ -213,7 +215,9 @@ import { is } from "drizzle-orm";
213
215
  * session_state: text("session_state"),
214
216
  * },
215
217
  * (account) => ({
216
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
218
+ * compoundKey: primaryKey({
219
+ columns: [account.provider, account.providerAccountId],
220
+ }),
217
221
  * })
218
222
  * )
219
223
  *
@@ -233,7 +237,7 @@ import { is } from "drizzle-orm";
233
237
  * expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
234
238
  * },
235
239
  * (vt) => ({
236
- * compoundKey: primaryKey(vt.identifier, vt.token),
240
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
237
241
  * })
238
242
  * )
239
243
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../src/lib/sqlite.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,kBAAkB,EAClB,aAAa,EACd,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAA;AAElE,wBAAgB,YAAY,CAAC,WAAW,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDtD;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AAE3D,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,CAAC,OAAO,kBAAkB,CAAC,EAC/C,OAAO,2BAAuB,GAC7B,OAAO,CAwJT"}
1
+ {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../src/lib/sqlite.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,kBAAkB,EAClB,aAAa,EACd,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAA;AAElE,wBAAgB,YAAY,CAAC,WAAW,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDtD;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AAE3D,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,CAAC,OAAO,kBAAkB,CAAC,EAC/C,OAAO,2BAAuB,GAC7B,OAAO,CA6JT"}
package/lib/sqlite.js CHANGED
@@ -120,13 +120,16 @@ export function SQLiteDrizzleAdapter(client, tableFn = defaultSqliteTableFn) {
120
120
  return account;
121
121
  },
122
122
  async getUserByAccount(account) {
123
- const result = await client
123
+ const results = await client
124
124
  .select()
125
125
  .from(accounts)
126
126
  .leftJoin(users, eq(users.id, accounts.userId))
127
127
  .where(and(eq(accounts.provider, account.provider), eq(accounts.providerAccountId, account.providerAccountId)))
128
128
  .get();
129
- return result?.user ?? null;
129
+ if (!results) {
130
+ return null;
131
+ }
132
+ return Promise.resolve(results).then((results) => results.user);
130
133
  },
131
134
  async deleteSession(sessionToken) {
132
135
  const result = await client
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,E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AA;IAClD,EAAE,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACzC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;CACtD;AAED,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,aAAa,GACb,iBAAiB,CAAA;AAErB,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI,MAAM,SAAS,gBAAgB,GAC/D,aAAa,CAAC,OAAO,CAAC,GACtB,MAAM,SAAS,aAAa,GAC1B,aAAa,CAAC,IAAI,CAAC,GACnB,MAAM,SAAS,iBAAiB,GAC9B,aAAa,CAAC,QAAQ,CAAC,GACvB,KAAK,CAAA;AAEb,MAAM,MAAM,OAAO,CAAC,MAAM,IAAI,MAAM,SAAS,gBAAgB,GACzD,YAAY,GACZ,MAAM,SAAS,aAAa,GAC1B,SAAS,GACT,MAAM,SAAS,iBAAiB,GAC9B,aAAa,GACb,cAAc,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth/drizzle-adapter",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "description": "Drizzle adapter for Auth.js.",
5
5
  "homepage": "https://authjs.dev",
6
6
  "repository": "https://github.com/nextauthjs/next-auth",
@@ -36,7 +36,7 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@auth/core": "0.18.6"
39
+ "@auth/core": "0.19.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@libsql/client": "0.4.0-pre.5",
package/src/index.ts CHANGED
@@ -98,7 +98,7 @@ import type { Adapter } from "@auth/core/adapters"
98
98
  * session_state: text("session_state"),
99
99
  * },
100
100
  * (account) => ({
101
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
101
+ * compoundKey: primaryKey({ columns: [account.provider, account.providerAccountId] }),
102
102
  * })
103
103
  * )
104
104
  *
@@ -118,7 +118,7 @@ import type { Adapter } from "@auth/core/adapters"
118
118
  * expires: timestamp("expires", { mode: "date" }).notNull(),
119
119
  * },
120
120
  * (vt) => ({
121
- * compoundKey: primaryKey(vt.identifier, vt.token),
121
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
122
122
  * })
123
123
  * )
124
124
  * ```
@@ -161,7 +161,9 @@ import type { Adapter } from "@auth/core/adapters"
161
161
  * session_state: varchar("session_state", { length: 255 }),
162
162
  * },
163
163
  * (account) => ({
164
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
164
+ * compoundKey: primaryKey({
165
+ columns: [account.provider, account.providerAccountId],
166
+ }),
165
167
  * })
166
168
  * )
167
169
  *
@@ -181,7 +183,7 @@ import type { Adapter } from "@auth/core/adapters"
181
183
  * expires: timestamp("expires", { mode: "date" }).notNull(),
182
184
  * },
183
185
  * (vt) => ({
184
- * compoundKey: primaryKey(vt.identifier, vt.token),
186
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
185
187
  * })
186
188
  * )
187
189
  * ```
@@ -218,7 +220,9 @@ import type { Adapter } from "@auth/core/adapters"
218
220
  * session_state: text("session_state"),
219
221
  * },
220
222
  * (account) => ({
221
- * compoundKey: primaryKey(account.provider, account.providerAccountId),
223
+ * compoundKey: primaryKey({
224
+ columns: [account.provider, account.providerAccountId],
225
+ }),
222
226
  * })
223
227
  * )
224
228
  *
@@ -238,7 +242,7 @@ import type { Adapter } from "@auth/core/adapters"
238
242
  * expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
239
243
  * },
240
244
  * (vt) => ({
241
- * compoundKey: primaryKey(vt.identifier, vt.token),
245
+ * compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
242
246
  * })
243
247
  * )
244
248
  * ```
package/src/lib/sqlite.ts CHANGED
@@ -153,7 +153,7 @@ export function SQLiteDrizzleAdapter(
153
153
  return account
154
154
  },
155
155
  async getUserByAccount(account) {
156
- const result = await client
156
+ const results = await client
157
157
  .select()
158
158
  .from(accounts)
159
159
  .leftJoin(users, eq(users.id, accounts.userId))
@@ -164,7 +164,12 @@ export function SQLiteDrizzleAdapter(
164
164
  )
165
165
  )
166
166
  .get()
167
- return result?.user ?? null
167
+
168
+ if (!results) {
169
+ return null;
170
+ }
171
+ return Promise.resolve(results).then((results) => results.user)
172
+
168
173
  },
169
174
  async deleteSession(sessionToken) {
170
175
  const result = await client
package/src/lib/utils.ts CHANGED
@@ -27,15 +27,15 @@ export type SqlFlavorOptions =
27
27
  export type ClientFlavors<Flavor> = Flavor extends AnyMySqlDatabase
28
28
  ? MinimumSchema["mysql"]
29
29
  : Flavor extends AnyPgDatabase
30
- ? MinimumSchema["pg"]
31
- : Flavor extends AnySQLiteDatabase
32
- ? MinimumSchema["sqlite"]
33
- : never
30
+ ? MinimumSchema["pg"]
31
+ : Flavor extends AnySQLiteDatabase
32
+ ? MinimumSchema["sqlite"]
33
+ : never
34
34
 
35
35
  export type TableFn<Flavor> = Flavor extends AnyMySqlDatabase
36
36
  ? MySqlTableFn
37
37
  : Flavor extends AnyPgDatabase
38
- ? PgTableFn
39
- : Flavor extends AnySQLiteDatabase
40
- ? SQLiteTableFn
41
- : AnySQLiteTable
38
+ ? PgTableFn
39
+ : Flavor extends AnySQLiteDatabase
40
+ ? SQLiteTableFn
41
+ : AnySQLiteTable