chore: move the server to an independent folder

This commit is contained in:
RainbowBird
2026-08-02 18:43:57 +08:00
parent 771ba3f8a7
commit 4ccde2c96e
293 changed files with 176 additions and 3020 deletions
+59
View File
@@ -0,0 +1,59 @@
import type { InferInsertModel, InferSelectModel } from 'drizzle-orm'
import { relations } from 'drizzle-orm'
import { boolean, jsonb, pgTable, text, timestamp } from 'drizzle-orm/pg-core'
import { nanoid } from '../utils/id'
import { user } from './accounts'
// NOTICE: bare ownerId is intentional — no FK to user.id. better-auth hard-deletes
// the user row; a cascade would wipe these soft-delete archive rows.
// See `server/apps/api/docs/ai-context/account-deletion.md`.
export const userProviderConfigs = pgTable(
'user_provider_configs',
{
id: text('id').primaryKey().$defaultFn(() => nanoid()),
ownerId: text('owner_id').notNull(),
definitionId: text('definition_id').notNull(),
name: text('name').notNull(),
config: jsonb('config').notNull().default({}),
validated: boolean('validated').notNull().default(false),
validationBypassed: boolean('validation_bypassed').notNull().default(false),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at'),
},
)
export type UserProviderConfig = InferSelectModel<typeof userProviderConfigs>
export type NewUserProviderConfig = InferInsertModel<typeof userProviderConfigs>
export const userProviderConfigsRelations = relations(
userProviderConfigs,
({ one }) => ({
owner: one(user, {
fields: [userProviderConfigs.ownerId],
references: [user.id],
}),
}),
)
export const systemProviderConfigs = pgTable(
'system_provider_configs',
{
id: text('id').primaryKey().$defaultFn(() => nanoid()),
definitionId: text('definition_id').notNull(),
name: text('name').notNull(),
config: jsonb('config').notNull().default({}),
validated: boolean('validated').notNull().default(false),
validationBypassed: boolean('validation_bypassed').notNull().default(false),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull(),
deletedAt: timestamp('deleted_at'),
},
)
export type SystemProviderConfig = InferSelectModel<typeof systemProviderConfigs>
export type NewSystemProviderConfig = InferInsertModel<typeof systemProviderConfigs>