From 5d06fa58525593f2ad27faf487f1b366ac004252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Wed, 14 Jun 2023 13:38:15 +0200 Subject: [PATCH] feat: introduce `@auth/sequelize-adapter` (#7806) Database adapters are not dependent on Next.js features, so it makes sense to republish them under the `@auth/*` scope. This PR is part of a series to convert adapters, using `@auth/core` for types. BREAKING CHANGE: If you are coming from the previous adapter, change your `package.json`: ```diff - "@next-auth/sequelize-adapter": "0.0.0", + "@auth/sequelize-adapter": "0.0.0", ``` And run `npm install`, `yarn install` or `pnpm install` respectively. **Note:** This packages is published as ESM-only --- .github/ISSUE_TEMPLATE/3_bug_adapter.yml | 2 +- .github/issue-labeler.yml | 2 +- packages/adapter-sequelize/README.md | 10 +++---- packages/adapter-sequelize/package.json | 33 +++++++++++++++--------- packages/adapter-sequelize/src/index.ts | 10 +++---- packages/adapter-sequelize/tsconfig.json | 25 +++++++++++++++--- pnpm-lock.yaml | 5 ++-- turbo.json | 4 +-- 8 files changed, 59 insertions(+), 32 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/3_bug_adapter.yml b/.github/ISSUE_TEMPLATE/3_bug_adapter.yml index e600f199..50145a8e 100644 --- a/.github/ISSUE_TEMPLATE/3_bug_adapter.yml +++ b/.github/ISSUE_TEMPLATE/3_bug_adapter.yml @@ -30,7 +30,7 @@ body: - "@auth/neo4j-adapter" - "@auth/pouchdb-adapter" - "@auth/prisma-adapter" - - "@next-auth/sequelize-adapter" + - "@auth/sequelize-adapter" - "@next-auth/supabase-adapter" - "@auth/typeorm-adapter" - "@auth/upstash-redis-adapter" diff --git a/.github/issue-labeler.yml b/.github/issue-labeler.yml index 88b45b67..3c8d2248 100644 --- a/.github/issue-labeler.yml +++ b/.github/issue-labeler.yml @@ -28,7 +28,7 @@ prisma: - "@auth/prisma-adapter" sequelize: - - "@next-auth/sequelize-adapter" + - "@auth/sequelize-adapter" supabase: - "@next-auth/supabase-adapter" diff --git a/packages/adapter-sequelize/README.md b/packages/adapter-sequelize/README.md index 160ec535..4668786a 100644 --- a/packages/adapter-sequelize/README.md +++ b/packages/adapter-sequelize/README.md @@ -8,14 +8,14 @@

Sequelize Adapter - NextAuth.js / Auth.js

- + TypeScript - - npm + + npm - - Downloads + + Downloads Github Stars diff --git a/packages/adapter-sequelize/package.json b/packages/adapter-sequelize/package.json index d72d76a1..7a0a665c 100644 --- a/packages/adapter-sequelize/package.json +++ b/packages/adapter-sequelize/package.json @@ -1,14 +1,26 @@ { - "name": "@next-auth/sequelize-adapter", - "version": "1.0.8", - "description": "Sequelize adapter for next-auth.", + "name": "@auth/sequelize-adapter", + "version": "0.0.0.", + "description": "Sequelize adapter for Auth.js", "homepage": "https://authjs.dev", "repository": "https://github.com/nextauthjs/next-auth", "bugs": { "url": "https://github.com/nextauthjs/next-auth/issues" }, "author": "github.com/luke-j", - "main": "dist/index.js", + "type": "module", + "types": "./index.d.ts", + "files": [ + "*.js", + "*.d.ts*", + "src" + ], + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.js" + } + }, "license": "ISC", "keywords": [ "next-auth", @@ -21,25 +33,22 @@ "access": "public" }, "scripts": { - "test:wip": "jest", + "test": "jest", "build": "tsc" }, - "files": [ - "README.md", - "dist" - ], + "dependencies": { + "@auth/core": "workspace:*" + }, "peerDependencies": { - "next-auth": "^4", "sequelize": "^6.6.5" }, "devDependencies": { "@next-auth/adapter-test": "workspace:*", "@next-auth/tsconfig": "workspace:*", "jest": "^27.4.3", - "next-auth": "workspace:*", "sequelize": "^6.6.5" }, "jest": { "preset": "@next-auth/adapter-test/jest" } -} \ No newline at end of file +} diff --git a/packages/adapter-sequelize/src/index.ts b/packages/adapter-sequelize/src/index.ts index 7b8ab72d..e82ef6cc 100644 --- a/packages/adapter-sequelize/src/index.ts +++ b/packages/adapter-sequelize/src/index.ts @@ -9,10 +9,10 @@ * ## Installation * * ```bash npm2yarn2pnpm - * npm install next-auth @next-auth/sequelize-adapter sequelize + * npm install next-auth @auth/sequelize-adapter sequelize * ``` * - * @module @next-auth/sequelize-adapter + * @module @auth/sequelize-adapter */ import type { Adapter, @@ -70,7 +70,7 @@ export interface SequelizeAdapterOptions { * * ```javascript title="pages/api/auth/[...nextauth].js" * import NextAuth from "next-auth" - * import SequelizeAdapter from "@next-auth/sequelize-adapter" + * import SequelizeAdapter from "@auth/sequelize-adapter" * import { Sequelize } from "sequelize" * * // https://sequelize.org/master/manual/getting-started.html#connecting-to-a-database @@ -93,7 +93,7 @@ export interface SequelizeAdapterOptions { * * ```js * import NextAuth from "next-auth" - * import SequelizeAdapter from "@next-auth/sequelize-adapter" + * import SequelizeAdapter from "@auth/sequelize-adapter" * import Sequelize from 'sequelize' * * const sequelize = new Sequelize("sqlite::memory:") @@ -117,7 +117,7 @@ export interface SequelizeAdapterOptions { * * ```js * import NextAuth from "next-auth" - * import SequelizeAdapter, { models } from "@next-auth/sequelize-adapter" + * import SequelizeAdapter, { models } from "@auth/sequelize-adapter" * import Sequelize, { DataTypes } from "sequelize" * * const sequelize = new Sequelize("sqlite::memory:") diff --git a/packages/adapter-sequelize/tsconfig.json b/packages/adapter-sequelize/tsconfig.json index 0b19a117..726c2dc1 100644 --- a/packages/adapter-sequelize/tsconfig.json +++ b/packages/adapter-sequelize/tsconfig.json @@ -1,8 +1,25 @@ { - "extends": "@next-auth/tsconfig/tsconfig.adapters.json", + "extends": "@next-auth/tsconfig/tsconfig.base.json", "compilerOptions": { + "allowJs": true, + "baseUrl": ".", + "isolatedModules": true, + "target": "ES2020", + "module": "ESNext", + "moduleResolution": "node", + "outDir": ".", "rootDir": "src", - "outDir": "dist" + "skipDefaultLibCheck": true, + "strictNullChecks": true, + "stripInternal": true, + "declarationMap": true, + "declaration": true }, - "exclude": ["tests", "dist", "jest.config.js"] -} + "include": [ + "src/**/*" + ], + "exclude": [ + "*.js", + "*.d.ts", + ] +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 539e804a..fc554e92 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -418,16 +418,17 @@ importers: packages/adapter-sequelize: specifiers: + '@auth/core': workspace:* '@next-auth/adapter-test': workspace:* '@next-auth/tsconfig': workspace:* jest: ^27.4.3 - next-auth: workspace:* sequelize: ^6.6.5 + dependencies: + '@auth/core': link:../core devDependencies: '@next-auth/adapter-test': link:../adapter-test '@next-auth/tsconfig': link:../tsconfig jest: 27.5.1 - next-auth: link:../next-auth sequelize: 6.21.0 packages/adapter-supabase: diff --git a/turbo.json b/turbo.json index ab396c74..cfff8526 100644 --- a/turbo.json +++ b/turbo.json @@ -63,7 +63,7 @@ "@auth/mongodb-adapter#build", "@auth/neo4j-adapter#build", "@auth/pouchdb-adapter#build", - "@next-auth/sequelize-adapter#build", + "@auth/sequelize-adapter#build", "@next-auth/supabase-adapter#build", "@auth/typeorm-adapter#build", "@auth/upstash-redis-adapter#build", @@ -86,7 +86,7 @@ "@auth/mongodb-adapter#build", "@auth/neo4j-adapter#build", "@auth/pouchdb-adapter#build", - "@next-auth/sequelize-adapter#build", + "@auth/sequelize-adapter#build", "@next-auth/supabase-adapter#build", "@auth/typeorm-adapter#build", "@auth/upstash-redis-adapter#build",