Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use NodeNext module resolution #9953

Merged
merged 29 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f70893a
refactor: set `moduleResolution` to `NodeNext`
balazsorban44 Feb 7, 2024
35c0bac
fix imports
balazsorban44 Feb 7, 2024
b603625
fix `next-auth` imports
balazsorban44 Feb 7, 2024
34db99c
chore: upgrade `next`
balazsorban44 Feb 7, 2024
e277700
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Apr 26, 2024
47f37d1
chore: fix root pnpm-lock
ndom91 Apr 26, 2024
95015e6
fix: cleanup next-auth/src/lib/actions.ts
ndom91 Apr 26, 2024
c6e5ac5
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Apr 26, 2024
2954505
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Apr 28, 2024
9f75e2b
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Apr 28, 2024
5bdbd2d
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Apr 28, 2024
c41780e
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Apr 29, 2024
b92dbfa
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 May 4, 2024
41e8161
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 May 14, 2024
62917d6
fix: pnpm-lock
ndom91 May 14, 2024
106cc28
fix: next-auth use next@latest
ndom91 May 14, 2024
6d153a9
fix: add simplewebauthn/server as dev dep for types
ndom91 May 14, 2024
acecb59
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 May 16, 2024
030744f
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 May 21, 2024
8049d9c
fix: pnpm-lock.yaml
ndom91 May 21, 2024
a7acee7
fix: use @simplewebuathn/types for broken tyupes
ndom91 May 21, 2024
525a3d0
fix: xata adapter incorrect types
ndom91 May 21, 2024
ed30673
fix: types in Dgraph adapter
ndom91 May 21, 2024
355d8c6
fix: rm unused imports in drizzle adapter
ndom91 May 21, 2024
140a6d5
fix: xata adapter building again
ndom91 May 21, 2024
7a661af
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Jun 1, 2024
d55b272
fix: pnpm-lock
ndom91 Jun 1, 2024
366fe42
chore: prettier
ndom91 Jun 1, 2024
39cc6cf
Merge branch 'main' into chore/nodnext-module-resolution
ndom91 Jun 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/adapter-d1/src/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { D1Database } from "."
import type { D1Database } from "./index.js"

export const upSQLStatements = [
`CREATE TABLE IF NOT EXISTS "accounts" (
Expand Down
48 changes: 30 additions & 18 deletions packages/adapter-dgraph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
*
* @module @auth/dgraph-adapter
*/
import { client as dgraphClient } from "./lib/client"
import { client as dgraphClient } from "./lib/client.js"
import { isDate, type Adapter } from "@auth/core/adapters"
import type { DgraphClientParams } from "./lib/client"
import * as defaultFragments from "./lib/graphql/fragments"
import type { DgraphClientParams } from "./lib/client.js"
import * as defaultFragments from "./lib/graphql/fragments.js"
import {
AdapterAccount,
AdapterSession,
AdapterUser,
VerificationToken,
} from "@auth/core/adapters"

export type { DgraphClientParams, DgraphClientError } from "./lib/client"
export type { DgraphClientParams, DgraphClientError } from "./lib/client.js"

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

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

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

return format.from<any>(result)
},
async getUserByEmail(email) {
async getUserByEmail(email: string) {
const [user] = await c.run<any>(
/* GraphQL */ `
query ($email: String = "") {
Expand All @@ -92,7 +98,10 @@ export function DgraphAdapter(
)
return format.from<any>(user)
},
async getUserByAccount(provider_providerAccountId) {
async getUserByAccount(provider_providerAccountId: {
provider: string
providerAccountId: string
}) {
const [account] = await c.run<any>(
/* GraphQL */ `
query ($providerAccountId: String = "", $provider: String = "") {
Expand All @@ -116,7 +125,7 @@ export function DgraphAdapter(
)
return format.from<any>(account?.user)
},
async updateUser({ id, ...input }) {
async updateUser({ id, ...input }: { id: string }) {
const result = await c.run<any>(
/* GraphQL */ `
mutation ($id: [ID!] = "", $input: UserPatch) {
Expand All @@ -132,7 +141,7 @@ export function DgraphAdapter(
)
return format.from<any>(result.user[0])
},
async deleteUser(id) {
async deleteUser(id: string) {
const result = await c.run<any>(
/* GraphQL */ `
mutation ($id: [ID!] = "") {
Expand Down Expand Up @@ -174,7 +183,7 @@ export function DgraphAdapter(
return deletedUser
},

async linkAccount(data) {
async linkAccount(data: AdapterAccount) {
const { userId, ...input } = data
await c.run<any>(
/* GraphQL */ `
Expand All @@ -191,7 +200,10 @@ export function DgraphAdapter(
)
return data
},
async unlinkAccount(provider_providerAccountId) {
async unlinkAccount(provider_providerAccountId: {
provider: string
providerAccountId: string
}) {
await c.run<any>(
/* GraphQL */ `
mutation ($providerAccountId: String = "", $provider: String = "") {
Expand All @@ -211,7 +223,7 @@ export function DgraphAdapter(
)
},

async getSessionAndUser(sessionToken) {
async getSessionAndUser(sessionToken: string) {
const [sessionAndUser] = await c.run<any>(
/* GraphQL */ `
query ($sessionToken: String = "") {
Expand All @@ -236,7 +248,7 @@ export function DgraphAdapter(
session: { ...format.from<any>(session), userId: user.id },
}
},
async createSession(data) {
async createSession(data: AdapterSession) {
const { userId, ...input } = data

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

return data as any
},
async updateSession({ sessionToken, ...input }) {
async updateSession({ sessionToken, ...input }: { sessionToken: string }) {
const result = await c.run<any>(
/* GraphQL */ `
mutation ($input: SessionPatch = {}, $sessionToken: String) {
Expand Down Expand Up @@ -283,7 +295,7 @@ export function DgraphAdapter(

return { ...session, userId: session.user.id }
},
async deleteSession(sessionToken) {
async deleteSession(sessionToken: string) {
await c.run<any>(
/* GraphQL */ `
mutation ($sessionToken: String = "") {
Expand All @@ -296,7 +308,7 @@ export function DgraphAdapter(
)
},

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

async useVerificationToken(params) {
async useVerificationToken(params: { identifier: string; token: string }) {
const result = await c.run<any>(
/* GraphQL */ `
mutation ($token: String = "", $identifier: String = "") {
Expand Down
4 changes: 1 addition & 3 deletions packages/adapter-drizzle/src/lib/mysql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InferInsertModel, and, eq, getTableColumns } from "drizzle-orm"
import { and, eq, getTableColumns } from "drizzle-orm"
import {
MySqlColumn,
MySqlDatabase,
Expand All @@ -8,10 +8,8 @@ import {
primaryKey,
timestamp,
varchar,
index,
QueryResultHKT,
PreparedQueryHKTBase,
TableConfig,
MySqlTableWithColumns,
} from "drizzle-orm/mysql-core"

Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-xata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"@auth/core": "workspace:*"
},
"peerDependencies": {
"@xata.io/client": ">=0.13.0"
"@xata.io/client": ">=0.28.0"
},
"devDependencies": {
"@xata.io/client": "^0.13.0"
"@xata.io/client": "^0.28.0"
}
}
2 changes: 1 addition & 1 deletion packages/adapter-xata/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/

import type { Adapter } from "@auth/core/adapters"
import type { XataClient } from "./xata"
import type { XataClient } from "./xata.js"

export function XataAdapter(client: XataClient): Adapter {
return {
Expand Down
171 changes: 157 additions & 14 deletions packages/adapter-xata/src/xata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
BaseClientOptions,
XataRecord,
ClientConstructor,
type BaseSchema,
} from "@xata.io/client"

export interface NextauthUser {
Expand Down Expand Up @@ -67,27 +68,169 @@ export interface NextauthSession {
export type NextauthSessionRecord = NextauthSession & XataRecord

export type DatabaseSchema = {
nextauth_users: NextauthUser
nextauth_accounts: NextauthAccount
nextauth_verificationTokens: NextauthVerificationToken
nextauth_users_accounts: NextauthUsersAccount
nextauth_users_sessions: NextauthUsersSession
nextauth_sessions: NextauthSession
nextauth_users: NextauthUserRecord
nextauth_accounts: NextauthAccountRecord
nextauth_verificationTokens: NextauthVerificationTokenRecord
nextauth_users_accounts: NextauthUsersAccountRecord
nextauth_users_sessions: NextauthUsersSessionRecord
nextauth_sessions: NextauthSessionRecord
}

const tables = [
"nextauth_users",
"nextauth_accounts",
"nextauth_verificationTokens",
"nextauth_users_accounts",
"nextauth_users_sessions",
"nextauth_sessions",
const schemas: BaseSchema[] = [
{
name: "nextauth_users",
columns: [
{
name: "email",
type: "email",
},
{
name: "emailVerified",
type: "datetime",
},
{
name: "name",
type: "string",
},
{
name: "image",
type: "string",
},
],
},
{
name: "nextauth_accounts",
columns: [
{
name: "user",
type: "link",
link: {
table: "nextauth_users",
},
},
{
name: "type",
type: "string",
},
{
name: "provider",
type: "string",
},
{
name: "providerAccountId",
type: "string",
},
{
name: "refresh_token",
type: "string",
},
{
name: "access_token",
type: "string",
},
{
name: "expires_at",
type: "int",
},
{
name: "token_type",
type: "string",
},
{
name: "scope",
type: "string",
},
{
name: "id_token",
type: "text",
},
{
name: "session_state",
type: "string",
},
],
},
{
name: "nextauth_verificationTokens",
columns: [
{
name: "identifier",
type: "string",
},
{
name: "token",
type: "string",
},
{
name: "expires",
type: "datetime",
},
],
},
{
name: "nextauth_users_accounts",
columns: [
{
name: "user",
type: "link",
link: {
table: "nextauth_users",
},
},
{
name: "account",
type: "link",
link: {
table: "nextauth_accounts",
},
},
],
},
{
name: "nextauth_users_sessions",
columns: [
{
name: "user",
type: "link",
link: {
table: "nextauth_users",
},
},
{
name: "session",
type: "link",
link: {
table: "nextauth_sessions",
},
},
],
},
{
name: "nextauth_sessions",
columns: [
{
name: "sessionToken",
type: "string",
},
{
name: "expires",
type: "datetime",
},
{
name: "user",
type: "link",
link: {
table: "nextauth_users",
},
},
],
},
]

const DatabaseClient = buildClient() as ClientConstructor<any>

export class XataClient extends DatabaseClient<DatabaseSchema> {
constructor(options?: BaseClientOptions) {
super({ databaseURL: "", ...options }, tables)
super({ databaseURL: "", ...options }, schemas)
}
}
Loading
Loading