Skip to content

Commit 577b7f9

Browse files
feat: use NodeNext module resolution (#9953)
Co-authored-by: Nico Domino <[email protected]>
1 parent 0b321a0 commit 577b7f9

File tree

17 files changed

+324
-290
lines changed

17 files changed

+324
-290
lines changed

packages/adapter-d1/src/migrations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { D1Database } from "."
1+
import type { D1Database } from "./index.js"
22

33
export const upSQLStatements = [
44
`CREATE TABLE IF NOT EXISTS "accounts" (

packages/adapter-dgraph/src/index.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
*
1515
* @module @auth/dgraph-adapter
1616
*/
17-
import { client as dgraphClient } from "./lib/client"
17+
import { client as dgraphClient } from "./lib/client.js"
1818
import { isDate, type Adapter } from "@auth/core/adapters"
19-
import type { DgraphClientParams } from "./lib/client"
20-
import * as defaultFragments from "./lib/graphql/fragments"
19+
import type { DgraphClientParams } from "./lib/client.js"
20+
import * as defaultFragments from "./lib/graphql/fragments.js"
21+
import {
22+
AdapterAccount,
23+
AdapterSession,
24+
AdapterUser,
25+
VerificationToken,
26+
} from "@auth/core/adapters"
2127

22-
export type { DgraphClientParams, DgraphClientError } from "./lib/client"
28+
export type { DgraphClientParams, DgraphClientError } from "./lib/client.js"
2329

2430
/** This is the interface of the Dgraph adapter options. */
2531
export interface DgraphAdapterOptions {
@@ -46,7 +52,7 @@ export function DgraphAdapter(
4652

4753
const fragments = { ...defaultFragments, ...options?.fragments }
4854
return {
49-
async createUser(input) {
55+
async createUser(input: AdapterUser) {
5056
const result = await c.run<{ user: any[] }>(
5157
/* GraphQL */ `
5258
mutation ($input: [AddUserInput!]!) {
@@ -63,7 +69,7 @@ export function DgraphAdapter(
6369

6470
return format.from<any>(result?.user[0])
6571
},
66-
async getUser(id) {
72+
async getUser(id: string) {
6773
const result = await c.run<any>(
6874
/* GraphQL */ `
6975
query ($id: ID!) {
@@ -78,7 +84,7 @@ export function DgraphAdapter(
7884

7985
return format.from<any>(result)
8086
},
81-
async getUserByEmail(email) {
87+
async getUserByEmail(email: string) {
8288
const [user] = await c.run<any>(
8389
/* GraphQL */ `
8490
query ($email: String = "") {
@@ -92,7 +98,10 @@ export function DgraphAdapter(
9298
)
9399
return format.from<any>(user)
94100
},
95-
async getUserByAccount(provider_providerAccountId) {
101+
async getUserByAccount(provider_providerAccountId: {
102+
provider: string
103+
providerAccountId: string
104+
}) {
96105
const [account] = await c.run<any>(
97106
/* GraphQL */ `
98107
query ($providerAccountId: String = "", $provider: String = "") {
@@ -116,7 +125,7 @@ export function DgraphAdapter(
116125
)
117126
return format.from<any>(account?.user)
118127
},
119-
async updateUser({ id, ...input }) {
128+
async updateUser({ id, ...input }: { id: string }) {
120129
const result = await c.run<any>(
121130
/* GraphQL */ `
122131
mutation ($id: [ID!] = "", $input: UserPatch) {
@@ -132,7 +141,7 @@ export function DgraphAdapter(
132141
)
133142
return format.from<any>(result.user[0])
134143
},
135-
async deleteUser(id) {
144+
async deleteUser(id: string) {
136145
const result = await c.run<any>(
137146
/* GraphQL */ `
138147
mutation ($id: [ID!] = "") {
@@ -174,7 +183,7 @@ export function DgraphAdapter(
174183
return deletedUser
175184
},
176185

177-
async linkAccount(data) {
186+
async linkAccount(data: AdapterAccount) {
178187
const { userId, ...input } = data
179188
await c.run<any>(
180189
/* GraphQL */ `
@@ -191,7 +200,10 @@ export function DgraphAdapter(
191200
)
192201
return data
193202
},
194-
async unlinkAccount(provider_providerAccountId) {
203+
async unlinkAccount(provider_providerAccountId: {
204+
provider: string
205+
providerAccountId: string
206+
}) {
195207
await c.run<any>(
196208
/* GraphQL */ `
197209
mutation ($providerAccountId: String = "", $provider: String = "") {
@@ -211,7 +223,7 @@ export function DgraphAdapter(
211223
)
212224
},
213225

214-
async getSessionAndUser(sessionToken) {
226+
async getSessionAndUser(sessionToken: string) {
215227
const [sessionAndUser] = await c.run<any>(
216228
/* GraphQL */ `
217229
query ($sessionToken: String = "") {
@@ -236,7 +248,7 @@ export function DgraphAdapter(
236248
session: { ...format.from<any>(session), userId: user.id },
237249
}
238250
},
239-
async createSession(data) {
251+
async createSession(data: AdapterSession) {
240252
const { userId, ...input } = data
241253

242254
await c.run<any>(
@@ -255,7 +267,7 @@ export function DgraphAdapter(
255267

256268
return data as any
257269
},
258-
async updateSession({ sessionToken, ...input }) {
270+
async updateSession({ sessionToken, ...input }: { sessionToken: string }) {
259271
const result = await c.run<any>(
260272
/* GraphQL */ `
261273
mutation ($input: SessionPatch = {}, $sessionToken: String) {
@@ -283,7 +295,7 @@ export function DgraphAdapter(
283295

284296
return { ...session, userId: session.user.id }
285297
},
286-
async deleteSession(sessionToken) {
298+
async deleteSession(sessionToken: string) {
287299
await c.run<any>(
288300
/* GraphQL */ `
289301
mutation ($sessionToken: String = "") {
@@ -296,7 +308,7 @@ export function DgraphAdapter(
296308
)
297309
},
298310

299-
async createVerificationToken(input) {
311+
async createVerificationToken(input: VerificationToken) {
300312
const result = await c.run<any>(
301313
/* GraphQL */ `
302314
mutation ($input: [AddVerificationTokenInput!]!) {
@@ -310,7 +322,7 @@ export function DgraphAdapter(
310322
return format.from<any>(result)
311323
},
312324

313-
async useVerificationToken(params) {
325+
async useVerificationToken(params: { identifier: string; token: string }) {
314326
const result = await c.run<any>(
315327
/* GraphQL */ `
316328
mutation ($token: String = "", $identifier: String = "") {

packages/adapter-drizzle/src/lib/mysql.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { InferInsertModel, and, eq, getTableColumns } from "drizzle-orm"
1+
import { and, eq, getTableColumns } from "drizzle-orm"
22
import {
33
MySqlColumn,
44
MySqlDatabase,
@@ -8,10 +8,8 @@ import {
88
primaryKey,
99
timestamp,
1010
varchar,
11-
index,
1211
QueryResultHKT,
1312
PreparedQueryHKTBase,
14-
TableConfig,
1513
MySqlTableWithColumns,
1614
} from "drizzle-orm/mysql-core"
1715

packages/adapter-xata/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
"@auth/core": "workspace:*"
4141
},
4242
"peerDependencies": {
43-
"@xata.io/client": ">=0.13.0"
43+
"@xata.io/client": ">=0.28.0"
4444
},
4545
"devDependencies": {
46-
"@xata.io/client": "^0.13.0"
46+
"@xata.io/client": "^0.28.0"
4747
}
4848
}

packages/adapter-xata/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131

3232
import type { Adapter } from "@auth/core/adapters"
33-
import type { XataClient } from "./xata"
33+
import type { XataClient } from "./xata.js"
3434

3535
export function XataAdapter(client: XataClient): Adapter {
3636
return {

packages/adapter-xata/src/xata.ts

Lines changed: 157 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
BaseClientOptions,
99
XataRecord,
1010
ClientConstructor,
11+
type BaseSchema,
1112
} from "@xata.io/client"
1213

1314
export interface NextauthUser {
@@ -67,27 +68,169 @@ export interface NextauthSession {
6768
export type NextauthSessionRecord = NextauthSession & XataRecord
6869

6970
export type DatabaseSchema = {
70-
nextauth_users: NextauthUser
71-
nextauth_accounts: NextauthAccount
72-
nextauth_verificationTokens: NextauthVerificationToken
73-
nextauth_users_accounts: NextauthUsersAccount
74-
nextauth_users_sessions: NextauthUsersSession
75-
nextauth_sessions: NextauthSession
71+
nextauth_users: NextauthUserRecord
72+
nextauth_accounts: NextauthAccountRecord
73+
nextauth_verificationTokens: NextauthVerificationTokenRecord
74+
nextauth_users_accounts: NextauthUsersAccountRecord
75+
nextauth_users_sessions: NextauthUsersSessionRecord
76+
nextauth_sessions: NextauthSessionRecord
7677
}
7778

78-
const tables = [
79-
"nextauth_users",
80-
"nextauth_accounts",
81-
"nextauth_verificationTokens",
82-
"nextauth_users_accounts",
83-
"nextauth_users_sessions",
84-
"nextauth_sessions",
79+
const schemas: BaseSchema[] = [
80+
{
81+
name: "nextauth_users",
82+
columns: [
83+
{
84+
name: "email",
85+
type: "email",
86+
},
87+
{
88+
name: "emailVerified",
89+
type: "datetime",
90+
},
91+
{
92+
name: "name",
93+
type: "string",
94+
},
95+
{
96+
name: "image",
97+
type: "string",
98+
},
99+
],
100+
},
101+
{
102+
name: "nextauth_accounts",
103+
columns: [
104+
{
105+
name: "user",
106+
type: "link",
107+
link: {
108+
table: "nextauth_users",
109+
},
110+
},
111+
{
112+
name: "type",
113+
type: "string",
114+
},
115+
{
116+
name: "provider",
117+
type: "string",
118+
},
119+
{
120+
name: "providerAccountId",
121+
type: "string",
122+
},
123+
{
124+
name: "refresh_token",
125+
type: "string",
126+
},
127+
{
128+
name: "access_token",
129+
type: "string",
130+
},
131+
{
132+
name: "expires_at",
133+
type: "int",
134+
},
135+
{
136+
name: "token_type",
137+
type: "string",
138+
},
139+
{
140+
name: "scope",
141+
type: "string",
142+
},
143+
{
144+
name: "id_token",
145+
type: "text",
146+
},
147+
{
148+
name: "session_state",
149+
type: "string",
150+
},
151+
],
152+
},
153+
{
154+
name: "nextauth_verificationTokens",
155+
columns: [
156+
{
157+
name: "identifier",
158+
type: "string",
159+
},
160+
{
161+
name: "token",
162+
type: "string",
163+
},
164+
{
165+
name: "expires",
166+
type: "datetime",
167+
},
168+
],
169+
},
170+
{
171+
name: "nextauth_users_accounts",
172+
columns: [
173+
{
174+
name: "user",
175+
type: "link",
176+
link: {
177+
table: "nextauth_users",
178+
},
179+
},
180+
{
181+
name: "account",
182+
type: "link",
183+
link: {
184+
table: "nextauth_accounts",
185+
},
186+
},
187+
],
188+
},
189+
{
190+
name: "nextauth_users_sessions",
191+
columns: [
192+
{
193+
name: "user",
194+
type: "link",
195+
link: {
196+
table: "nextauth_users",
197+
},
198+
},
199+
{
200+
name: "session",
201+
type: "link",
202+
link: {
203+
table: "nextauth_sessions",
204+
},
205+
},
206+
],
207+
},
208+
{
209+
name: "nextauth_sessions",
210+
columns: [
211+
{
212+
name: "sessionToken",
213+
type: "string",
214+
},
215+
{
216+
name: "expires",
217+
type: "datetime",
218+
},
219+
{
220+
name: "user",
221+
type: "link",
222+
link: {
223+
table: "nextauth_users",
224+
},
225+
},
226+
],
227+
},
85228
]
86229

87230
const DatabaseClient = buildClient() as ClientConstructor<any>
88231

89232
export class XataClient extends DatabaseClient<DatabaseSchema> {
90233
constructor(options?: BaseClientOptions) {
91-
super({ databaseURL: "", ...options }, tables)
234+
super({ databaseURL: "", ...options }, schemas)
92235
}
93236
}

0 commit comments

Comments
 (0)