chore: format code

This commit is contained in:
GitHub Action
2025-11-08 01:59:02 +00:00
parent 16357e8041
commit 34ff87d504
182 changed files with 940 additions and 3646 deletions

View File

@@ -24,40 +24,37 @@ export namespace AWS {
body: z.string(),
}),
async (input) => {
const res = await createClient().fetch(
"https://email.us-east-1.amazonaws.com/v2/email/outbound-emails",
{
method: "POST",
headers: {
"X-Amz-Target": "SES.SendEmail",
"Content-Type": "application/json",
const res = await createClient().fetch("https://email.us-east-1.amazonaws.com/v2/email/outbound-emails", {
method: "POST",
headers: {
"X-Amz-Target": "SES.SendEmail",
"Content-Type": "application/json",
},
body: JSON.stringify({
FromEmailAddress: `OpenCode Zen <contact@anoma.ly>`,
Destination: {
ToAddresses: [input.to],
},
body: JSON.stringify({
FromEmailAddress: `OpenCode Zen <contact@anoma.ly>`,
Destination: {
ToAddresses: [input.to],
},
Content: {
Simple: {
Subject: {
Content: {
Simple: {
Subject: {
Charset: "UTF-8",
Data: input.subject,
},
Body: {
Text: {
Charset: "UTF-8",
Data: input.subject,
Data: input.body,
},
Body: {
Text: {
Charset: "UTF-8",
Data: input.body,
},
Html: {
Charset: "UTF-8",
Data: input.body,
},
Html: {
Charset: "UTF-8",
Data: input.body,
},
},
},
}),
},
)
},
}),
})
if (!res.ok) {
throw new Error(`Failed to send email: ${res.statusText}`)
}

View File

@@ -5,10 +5,7 @@ import { Client } from "@planetscale/database"
import { MySqlTransaction, type MySqlTransactionConfig } from "drizzle-orm/mysql-core"
import type { ExtractTablesWithRelations } from "drizzle-orm"
import type {
PlanetScalePreparedQueryHKT,
PlanetscaleQueryResultHKT,
} from "drizzle-orm/planetscale-serverless"
import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "drizzle-orm/planetscale-serverless"
import { Context } from "../context"
import { memo } from "../util/memo"
@@ -70,10 +67,7 @@ export namespace Database {
}
}
export async function transaction<T>(
callback: (tx: TxOrDb) => Promise<T>,
config?: MySqlTransactionConfig,
) {
export async function transaction<T>(callback: (tx: TxOrDb) => Promise<T>, config?: MySqlTransactionConfig) {
try {
const { tx } = TransactionContext.use()
return callback(tx)

View File

@@ -20,14 +20,8 @@ export namespace Key {
email: AuthTable.subject,
})
.from(KeyTable)
.innerJoin(
UserTable,
and(eq(KeyTable.userID, UserTable.id), eq(KeyTable.workspaceID, UserTable.workspaceID)),
)
.innerJoin(
AuthTable,
and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")),
)
.innerJoin(UserTable, and(eq(KeyTable.userID, UserTable.id), eq(KeyTable.workspaceID, UserTable.workspaceID)))
.innerJoin(AuthTable, and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")))
.where(
and(
...[

View File

@@ -60,9 +60,7 @@ export namespace Model {
export const enable = fn(z.object({ model: z.string() }), ({ model }) => {
Actor.assertAdmin()
return Database.use((db) =>
db
.delete(ModelTable)
.where(and(eq(ModelTable.workspaceID, Actor.workspace()), eq(ModelTable.model, model))),
db.delete(ModelTable).where(and(eq(ModelTable.workspaceID, Actor.workspace()), eq(ModelTable.model, model))),
)
})

View File

@@ -11,9 +11,7 @@ export namespace Provider {
tx
.select()
.from(ProviderTable)
.where(
and(eq(ProviderTable.workspaceID, Actor.workspace()), isNull(ProviderTable.timeDeleted)),
),
.where(and(eq(ProviderTable.workspaceID, Actor.workspace()), isNull(ProviderTable.timeDeleted))),
),
)
@@ -52,12 +50,7 @@ export namespace Provider {
return Database.transaction((tx) =>
tx
.delete(ProviderTable)
.where(
and(
eq(ProviderTable.provider, provider),
eq(ProviderTable.workspaceID, Actor.workspace()),
),
),
.where(and(eq(ProviderTable.provider, provider), eq(ProviderTable.workspaceID, Actor.workspace()))),
)
},
)

View File

@@ -1,11 +1,4 @@
import {
index,
mysqlEnum,
mysqlTable,
primaryKey,
uniqueIndex,
varchar,
} from "drizzle-orm/mysql-core"
import { index, mysqlEnum, mysqlTable, primaryKey, uniqueIndex, varchar } from "drizzle-orm/mysql-core"
import { id, timestamps, ulid } from "../drizzle/types"
export const AuthProvider = ["email", "github", "google"] as const

View File

@@ -9,8 +9,5 @@ export const ModelTable = mysqlTable(
...timestamps,
model: varchar("model", { length: 64 }).notNull(),
},
(table) => [
...workspaceIndexes(table),
uniqueIndex("model_workspace_model").on(table.workspaceID, table.model),
],
(table) => [...workspaceIndexes(table), uniqueIndex("model_workspace_model").on(table.workspaceID, table.model)],
)

View File

@@ -10,8 +10,5 @@ export const ProviderTable = mysqlTable(
provider: varchar("provider", { length: 64 }).notNull(),
credentials: text("credentials").notNull(),
},
(table) => [
...workspaceIndexes(table),
uniqueIndex("workspace_provider").on(table.workspaceID, table.provider),
],
(table) => [...workspaceIndexes(table), uniqueIndex("workspace_provider").on(table.workspaceID, table.provider)],
)

View File

@@ -1,12 +1,4 @@
import {
mysqlTable,
uniqueIndex,
varchar,
int,
mysqlEnum,
index,
bigint,
} from "drizzle-orm/mysql-core"
import { mysqlTable, uniqueIndex, varchar, int, mysqlEnum, index, bigint } from "drizzle-orm/mysql-core"
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
import { workspaceIndexes } from "./workspace.sql"

View File

@@ -26,10 +26,7 @@ export namespace User {
authEmail: AuthTable.subject,
})
.from(UserTable)
.leftJoin(
AuthTable,
and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")),
)
.leftJoin(AuthTable, and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")))
.where(and(eq(UserTable.workspaceID, Actor.workspace()), isNull(UserTable.timeDeleted))),
),
)
@@ -39,13 +36,7 @@ export namespace User {
tx
.select()
.from(UserTable)
.where(
and(
eq(UserTable.workspaceID, Actor.workspace()),
eq(UserTable.id, id),
isNull(UserTable.timeDeleted),
),
)
.where(and(eq(UserTable.workspaceID, Actor.workspace()), eq(UserTable.id, id), isNull(UserTable.timeDeleted)))
.then((rows) => rows[0]),
),
)
@@ -57,10 +48,7 @@ export namespace User {
email: AuthTable.subject,
})
.from(UserTable)
.leftJoin(
AuthTable,
and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")),
)
.leftJoin(AuthTable, and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")))
.where(and(eq(UserTable.workspaceID, Actor.workspace()), eq(UserTable.id, id)))
.then((rows) => rows[0]?.email),
),
@@ -142,16 +130,10 @@ export namespace User {
workspaceName: WorkspaceTable.name,
})
.from(UserTable)
.innerJoin(
AuthTable,
and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")),
)
.innerJoin(AuthTable, and(eq(UserTable.accountID, AuthTable.accountID), eq(AuthTable.provider, "email")))
.innerJoin(WorkspaceTable, eq(WorkspaceTable.id, workspaceID))
.where(
and(
eq(UserTable.workspaceID, workspaceID),
eq(UserTable.id, Actor.assert("user").properties.userID),
),
and(eq(UserTable.workspaceID, workspaceID), eq(UserTable.id, Actor.assert("user").properties.userID)),
)
.then((rows) => rows[0]),
)