Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

chore: clean up types + deps (#1391)

bautistaaac6e190b2a61d
diff --git a/apps/admin/package.json b/apps/admin/package.json
index 5ed55de1..49b0fefe 100644
--- a/apps/admin/package.json
+++ b/apps/admin/package.json
@@ -27,7 +27,6 @@
"clsx": "^2.0.0",
"million": "2.6.0-beta.12",
"next": "14.0.1",
- "next-auth": "^4.22.1",
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-dnd": "^16.0.1",
diff --git a/package.json b/package.json
index cee54295..9a31fbde 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,9 @@
},
"packageManager": "[email protected]",
"pnpm": {
+ "overrides": {
+ "@auth/core": "0.19.0"
+ },
"peerDependencyRules": {
"ignoreMissing": [
"monaco-editor"
diff --git a/packages/auth/package.json b/packages/auth/package.json
index 813300bb..159c2a07 100644
--- a/packages/auth/package.json
+++ b/packages/auth/package.json
@@ -29,7 +29,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
- "@auth/prisma-adapter": "^1.0.12",
+ "@auth/prisma-adapter": "^1.0.13",
"@repo/db": "workspace:*",
"next-auth": "5.0.0-beta.4"
},
diff --git a/packages/auth/src/server.ts b/packages/auth/src/server.ts
index 510cf686..827f83d3 100644
--- a/packages/auth/src/server.ts
+++ b/packages/auth/src/server.ts
@@ -1,7 +1,5 @@
import { PrismaAdapter } from '@auth/prisma-adapter';
-import type { Role, RoleTypes } from '@repo/db/types';
-import type { Adapter, AdapterUser, AdapterSession } from '@auth/core/adapters';
-import { type DefaultSession, type User } from 'next-auth';
+import type { Role, RoleTypes, User } from '@repo/db/types';
import GitHubProvider from 'next-auth/providers/github';
import { prisma } from '@repo/db';
import NextAuth from './next-auth';
@@ -16,14 +14,12 @@ export type { Session, DefaultSession as DefaultAuthSession } from 'next-auth';
*/
declare module 'next-auth' {
interface Session {
- user: DefaultSession['user'] & {
- id: string;
- role: RoleTypes[];
- };
+ user: User & { role: RoleTypes[] };
}
+}
- interface User {
- createdAt: Date;
+declare module '@auth/core/adapters' {
+ interface AdapterUser extends User {
roles: Role[];
}
}
@@ -60,10 +56,10 @@ export const {
},
},
adapter: {
- ...(PrismaAdapter(prisma) as Adapter),
+ ...PrismaAdapter(prisma),
// Override createUser method to add default USER role
- createUser: (data) =>
- prisma.user.create({
+ createUser: async (data) => {
+ const user = await prisma.user.create({
data: {
...data,
name: data.name ?? '',
@@ -75,7 +71,9 @@ export const {
},
},
include: { roles: true },
- }) as Promise<AdapterUser>,
+ });
+ return user;
+ },
// Override getSessionAndUser method to include roles. Avoids a second db query in session callback
getSessionAndUser: async (sessionToken) => {
const userAndSession = await prisma.session.findUnique({
@@ -84,11 +82,14 @@ export const {
});
if (!userAndSession) return null;
const { user, ...session } = userAndSession;
- return { user, session } as { session: AdapterSession; user: AdapterUser };
+ return { user, session };
},
},
callbacks: {
- session: async ({ session, user }) => {
+ session: async (opts) => {
+ if (!('user' in opts)) throw new Error("unreachable, we're not using JWT");
+
+ const { session, user } = opts;
return {
...session,
user: {
@@ -103,13 +104,12 @@ export const {
GitHubProvider({
clientId: process.env.GITHUB_ID!,
clientSecret: process.env.GITHUB_SECRET!,
- profile: (p) =>
- ({
- id: p.id.toString(),
- name: p.login,
- email: p.email,
- image: p.avatar_url,
- }) as User, // TODO: Remove typecast
+ profile: (p) => ({
+ id: p.id.toString(),
+ name: p.login,
+ email: p.email,
+ image: p.avatar_url,
+ }),
}),
],
});
diff --git a/packages/db/schema.prisma b/packages/db/schema.prisma
index e58a2d9e..7c1d66d0 100644
--- a/packages/db/schema.prisma
+++ b/packages/db/schema.prisma
@@ -100,7 +100,7 @@ model User {
id String @id @default(uuid())
name String
- email String? @unique
+ email String @unique
emailVerified DateTime?
image String?
roles Role[]
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2aba3f52..8c456149 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -4,6 +4,9 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
+overrides:
+ '@auth/core': 0.19.0
+
patchedDependencies:
'@monaco-editor/[email protected]':
hash: xep4qb27qzc6gvlhv2fxe3r2ka
@@ -91,9 +94,6 @@ importers:
next:
specifier: 14.0.1
- next-auth:
- specifier: ^4.22.1
next-themes:
specifier: ^0.2.1
@@ -180,7 +180,7 @@ importers:
apps/auth-proxy:
dependencies:
'@auth/core':
- specifier: ^0.19.0
+ specifier: 0.19.0
version: 0.19.0
devDependencies:
'@repo/lint':
@@ -489,8 +489,8 @@ importers:
packages/auth:
dependencies:
'@auth/prisma-adapter':
- specifier: ^1.0.12
- version: 1.0.12(@prisma/[email protected])
+ specifier: ^1.0.13
+ version: 1.0.13(@prisma/[email protected])
'@repo/db':
specifier: workspace:*
version: link:../db
@@ -764,7 +764,7 @@ importers:
dependencies:
'@next/eslint-plugin-next':
specifier: canary
- version: 13.4.20-canary.0
+ version: 14.0.5-canary.35
'@repo/tsconfig':
specifier: workspace:*
version: link:../config-typescript
@@ -776,7 +776,7 @@ importers:
'@vercel/style-guide':
specifier: ^4.0.2
eslint:
specifier: ^8.45.0
version: 8.45.0
@@ -961,22 +961,6 @@ packages:
'@jridgewell/trace-mapping': 0.3.18
dev: false
- resolution: {integrity: sha512-GsNhsP1xE/3FoNS3dVkPjqRljLNJ4iyL2OLv3klQGNvw3bMpROFcK4lqhx7+pPHiamnVaYt2vg1xbB+lsNaevg==}
- peerDependencies:
- nodemailer: ^6.8.0
- peerDependenciesMeta:
- nodemailer:
- optional: true
- dependencies:
- '@panva/hkdf': 1.1.1
- cookie: 0.6.0
- jose: 5.1.3
- oauth4webapi: 2.4.0
- preact: 10.11.3
- preact-render-to-string: 5.2.3([email protected])
- dev: false
-
resolution: {integrity: sha512-BkFg2SoNftMN6A2Sn2g1lLFLTO74qMtFKsZmSCEF9d1csqSaEXIv50k6OrfniODWi5tZP8bcfSxGodv75khlOA==}
peerDependencies:
@@ -994,8 +978,8 @@ packages:
preact-render-to-string: 5.2.3([email protected])
dev: false
- resolution: {integrity: sha512-vLsbIgvpJUVpQLCDvSG16bg/uisf6y2TYHzgR1zriwMu3WdrhuG2RxrypNHNdhJZoGW0mL57QEvGVh+C9AtsRA==}
+ resolution: {integrity: sha512-JIlmIrvTkDHl8nG7fn17aJcIHu7wfXqRJJmrNR8UtDNN/1WgfEs66WrYZIK6d96aT6WR+fB/8PqvAG+8Hj9OEw==}
peerDependencies:
'@prisma/client': '>=2.26.0 || >=3 || >=4 || >=5'
dependencies:
@@ -2830,8 +2814,8 @@ packages:
glob: 7.1.7
dev: true
- resolution: {integrity: sha512-vFC1meiw/awh2xJZMWaoECsfZbgkt2fF3HIg8f2fSM/w41Z86L1SS7SjKmpbbD87yq3tiqgqHmFv0JCych4g4g==}
+ resolution: {integrity: sha512-E49+IC/7hwVFl9Z5bdPvS95MYtqAR6Zsza39vGGtDrZi3uxRe4b1DXdTlLuYpIT+LOLrZLYx/j9hoiViYmfGgQ==}
dependencies:
glob: 7.1.7
dev: false
@@ -2964,7 +2948,7 @@ packages:
'@octokit/request-error': 5.0.0
'@octokit/types': 11.1.0
deprecation: 2.3.1
- lru-cache: 10.1.0
+ lru-cache: 10.0.0
universal-github-app-jwt: 1.1.1
universal-user-agent: 6.0.0
dev: true
@@ -5995,7 +5979,7 @@ packages:
yoga-wasm-web: 0.3.0
dev: false
resolution: {integrity: sha512-FroL+oOePzhw7n/I+f7zr4WNroGHT/+2TlW6WH9+CVSjMNsEyu7Qstj2mI5gWIBjT1Y2ZImKPppCzI2cIYmNZw==}
engines: {node: '>=16'}
peerDependencies:
@@ -6015,7 +5999,7 @@ packages:
dependencies:
'@babel/core': 7.22.10
'@babel/eslint-parser': 7.22.10(@babel/[email protected])([email protected])
- '@next/eslint-plugin-next': 13.4.20-canary.0
+ '@next/eslint-plugin-next': 14.0.5-canary.35
'@rushstack/eslint-patch': 1.3.2
'@typescript-eslint/eslint-plugin': 5.59.1(@typescript-eslint/[email protected])([email protected])([email protected])
'@typescript-eslint/parser': 5.62.0([email protected])([email protected])
@@ -10200,10 +10184,6 @@ packages:
resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==}
dev: false
- resolution: {integrity: sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==}
- dev: false
-
resolution: {integrity: sha512-GPExOkcMsCLBTi1YetY2LmkoY559fss0+0KVa6kOfb2YFe84nAM7Nm/XzuZozah4iHgmBGrCOHL5/cy670SBRw==}
dev: false
@@ -10543,6 +10523,11 @@ packages:
highlight.js: 10.7.3
dev: false
+ resolution: {integrity: sha512-svTf/fzsKHffP42sujkO/Rjs37BCIsQVRCeNYIm9WN8rgT7ffoUnRtZCqU+6BqcSBdv8gwJeTz8knJpgACeQMw==}
+ engines: {node: 14 || >=16.14}
+ dev: true
+
resolution: {integrity: sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==}
engines: {node: 14 || >=16.14}
@@ -11268,31 +11253,6 @@ packages:
resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}
- resolution: {integrity: sha512-NTR3f6W7/AWXKw8GSsgSyQcDW6jkslZLH8AiZa5PQ09w1kR8uHtR9rez/E9gAq/o17+p0JYHE8QjF3RoniiObA==}
- peerDependencies:
- next: ^12.2.5 || ^13
- nodemailer: ^6.6.5
- react: ^17.0.2 || ^18
- react-dom: ^17.0.2 || ^18
- peerDependenciesMeta:
- nodemailer:
- optional: true
- dependencies:
- '@babel/runtime': 7.22.6
- '@panva/hkdf': 1.1.1
- cookie: 0.5.0
- jose: 4.15.4
- oauth: 0.9.15
- openid-client: 5.6.3
- preact: 10.16.0
- preact-render-to-string: 5.2.3([email protected])
- react: 18.2.0
- react-dom: 18.2.0([email protected])
- uuid: 8.3.2
- dev: false
-
resolution: {integrity: sha512-vgocjvwPA8gxd/zrIP/vr9lJ/HeNe+C56lPP1D3sdyenHt8KncQV6ro7q0xCsDp1fcOKx7WAWVZH5o8aMxDzgw==}
peerDependencies:
@@ -11303,7 +11263,7 @@ packages:
nodemailer:
optional: true
dependencies:
- '@auth/core': 0.18.4
+ '@auth/core': 0.19.0
react: 18.2.0
dev: false
@@ -11607,19 +11567,10 @@ packages:
resolution: {integrity: sha512-ZWl8ov8HeGVyc9Icl1cag76HvIcDAp23eIIT+UVGir+dEu8BMgMlvZeZwqLVd0P8DqaumH4N+QLQXN69G1QjSA==}
dev: false
- resolution: {integrity: sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA==}
- dev: false
-
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
engines: {node: '>=0.10.0'}
- resolution: {integrity: sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==}
- engines: {node: '>= 6'}
- dev: false
-
resolution: {integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==}
engines: {node: '>= 6'}
@@ -11697,11 +11648,6 @@ packages:
resolution: {integrity: sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw==}
dev: true
- resolution: {integrity: sha512-IF4PcGgzAr6XXSff26Sk/+P4KZFJVuHAJZj3wgO3vX2bMdNVp/QXTP3P7CEm9V1IdG8lDLY3HhiqpsE/nOwpPw==}
- engines: {node: ^10.13.0 || >=12.0.0}
- dev: false
-
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
engines: {node: '>= 0.8'}
@@ -11761,15 +11707,6 @@ packages:
hasBin: true
dev: false
- resolution: {integrity: sha512-lZrvkveRtmeVq2LBJbdI7UcTlAOz0YXeWd2gEfc9Nj6NUinX/HdfKN2RnDqwRy5jnGxXUWAKyg3xYDwF/LuKNw==}
- dependencies:
- jose: 4.15.4
- lru-cache: 6.0.0
- object-hash: 2.2.0
- oidc-token-hash: 5.0.3
- dev: false
-
resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==}
engines: {node: '>= 0.8.0'}
@@ -12181,15 +12118,6 @@ packages:
pretty-format: 3.8.0
dev: false
- resolution: {integrity: sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==}
- peerDependencies:
- preact: '>=10'
- dependencies:
- preact: 10.16.0
- pretty-format: 3.8.0
- dev: false
-
resolution: {integrity: sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==}
dev: false
@@ -14567,11 +14495,6 @@ packages:
js-sha1: 0.6.0
dev: true
- resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
- hasBin: true
- dev: false
-
resolution: {integrity: sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==}
engines: {node: '>=8'}
diff --git a/turbo.json b/turbo.json
index b2da379a..9e98d5c9 100644
--- a/turbo.json
+++ b/turbo.json
@@ -1,5 +1,4 @@
{
- "experimentalSpaces": { "id": "space_CWwpUyi1jEpIayj8iSDdz2Ze" },
"globalEnv": ["NEXT_PUBLIC_ALGOLIA_APP_ID", "NEXT_PUBLIC_ALGOLIA_API_KEY"],
"pipeline": {
"build": {