feat: remove workos; update drizzle fork

pull/715/head
Travis Fischer 2025-05-14 19:41:28 +07:00
rodzic c67a94529f
commit 05ae5e307e
7 zmienionych plików z 1095 dodań i 842 usunięć

Wyświetl plik

@ -37,20 +37,19 @@
},
"dependencies": {
"@agentic/validators": "workspace:*",
"@fisch0920/drizzle-orm": "^0.43.5",
"@fisch0920/drizzle-zod": "^0.7.7",
"@fisch0920/drizzle-orm": "^0.43.7",
"@fisch0920/drizzle-zod": "^0.7.9",
"@google-cloud/logging": "^11.2.0",
"@hono/node-server": "^1.14.1",
"@hono/sentry": "^1.2.1",
"@hono/zod-openapi": "^0.19.5",
"@hono/zod-validator": "^0.4.3",
"@hono/zod-openapi": "^0.19.6",
"@hono/zod-validator": "^0.5.0",
"@paralleldrive/cuid2": "^2.2.2",
"@sentry/node": "^9.14.0",
"@workos-inc/node": "^7.47.0",
"@sentry/node": "^9.19.0",
"bcryptjs": "^3.0.2",
"eventid": "^2.0.1",
"exit-hook": "catalog:",
"hono": "^4.7.7",
"hono": "^4.7.9",
"jsonwebtoken": "^9.0.2",
"p-all": "^5.0.0",
"pino": "^9.6.0",
@ -60,11 +59,11 @@
"stripe": "^18.1.0",
"type-fest": "catalog:",
"zod": "catalog:",
"zod-validation-error": "^3.4.0"
"zod-validation-error": "^3.4.1"
},
"devDependencies": {
"@types/jsonwebtoken": "^9.0.9",
"drizzle-kit": "^0.31.0",
"drizzle-kit": "^0.31.1",
"drizzle-orm": "^0.43.1"
}
}

Wyświetl plik

@ -1,60 +0,0 @@
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
import { setCookie } from 'hono/cookie'
import { env } from '@/lib/env'
import { assert } from '@/lib/utils'
import { workos } from '@/lib/workos'
const route = createRoute({
method: 'get',
path: 'auth/callback',
hide: true,
request: {
query: z.object({
code: z.string()
})
},
responses: {
302: {
description: 'Redirect'
}
}
})
export function registerAuthCallback(app: OpenAPIHono) {
return app.openapi(route, async (c) => {
const { code } = c.req.valid('query')
assert(code, 400, '"code" is required')
try {
const authenticateResponse =
await workos.userManagement.authenticateWithCode({
clientId: env.WORKOS_CLIENT_ID,
code,
session: {
sealSession: true,
cookiePassword: env.WORKOS_SESSION_SECRET
}
})
const { user: _user, sealedSession } = authenticateResponse
assert(sealedSession, 500, 'Sealed session is required')
// Store session in a cookie
setCookie(c, 'wos-session', sealedSession!, {
path: '/',
httpOnly: true,
secure: true,
sameSite: 'lax',
maxAge: 60 * 60 * 24 * 30 // 30 days
})
// TODO: `user`
// Redirect the user to the homepage
return c.redirect('/')
} catch {
return c.redirect('/auth/login')
}
})
}

Wyświetl plik

@ -1,39 +0,0 @@
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
import { env } from '@/lib/env'
import { workos } from '@/lib/workos'
const route = createRoute({
method: 'get',
path: 'auth/login',
hide: true,
request: {
query: z.object({
redirectUri: z.string().url().optional()
})
},
responses: {
302: {
description: 'Redirect to WorkOS login page'
}
}
})
export function registerAuthLogin(app: OpenAPIHono) {
return app.openapi(route, async (c) => {
const { redirectUri = 'http://localhost:3000/auth/callback' } =
c.req.valid('query')
const authorizationUrl = workos.userManagement.getAuthorizationUrl({
clientId: env.WORKOS_CLIENT_ID,
// Specify that we'd like AuthKit to handle the authentication flow
provider: 'authkit',
// The callback endpoint that WorkOS will redirect to after a user authenticates
redirectUri
})
return c.redirect(authorizationUrl)
})
}

Wyświetl plik

@ -1,14 +1,11 @@
import { expectTypeOf, test } from 'vitest'
import type { schema } from '.'
import type { User } from './types'
import type { RawUser, User } from './types'
type UserSelect = typeof schema.users.$inferSelect
type UserKeys = Exclude<keyof User, 'providers'>
test('User types are compatible', () => {
// TODO: { github?: AuthProvider | undefined } !== { github: AuthProvider | undefined }
expectTypeOf<UserSelect>().toExtend<User>()
expectTypeOf<RawUser>().toExtend<User>()
expectTypeOf<User[UserKeys]>().toEqualTypeOf<UserSelect[UserKeys]>()
expectTypeOf<User[UserKeys]>().toEqualTypeOf<RawUser[UserKeys]>()
})

Wyświetl plik

@ -1,7 +0,0 @@
import { WorkOS } from '@workos-inc/node'
import { env } from './env'
export const workos = new WorkOS(env.WORKOS_API_KEY, {
clientId: env.WORKOS_CLIENT_ID
})

Plik diff jest za duży Load Diff

Wyświetl plik

@ -3,29 +3,29 @@ packages:
- apps/*
catalog:
'@ai-sdk/openai': ^1.3.6
'@ai-sdk/openai': ^1.3.22
'@fisch0920/config': ^1.1.0
'@modelcontextprotocol/sdk': ^1.8.0
'@types/node': ^22.15.0
ai: ^4.2.11
'@modelcontextprotocol/sdk': ^1.11.2
'@types/node': ^22.15.18
ai: ^4.3.15
cleye: ^1.3.4
del-cli: ^6.0.0
dotenv: ^16.5.0
eslint: ^9.25.1
eslint: ^9.26.0
exit-hook: ^4.0.0
ky: ^1.8.0
lint-staged: ^15.5.1
npm-run-all2: ^7.0.2
ky: ^1.8.1
lint-staged: ^16.0.0
npm-run-all2: ^8.0.1
only-allow: ^1.2.1
p-map: ^7.0.3
p-throttle: 6.2.0
p-throttle: 7.0.0
prettier: ^3.5.3
restore-cursor: ^5.1.0
simple-git-hooks: ^2.13.0
tsup: ^8.4.0
tsx: ^4.19.3
turbo: ^2.5.1
type-fest: ^4.40.0
tsx: ^4.19.4
turbo: ^2.5.3
type-fest: ^4.41.0
typescript: ^5.8.3
vitest: ^3.1.2
zod: ^3.24.3
vitest: ^3.1.3
zod: ^3.24.4