🌐 chore: translate non-English comments to English in packages/database (#12975)

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
LobeHub Bot
2026-03-16 11:01:39 +08:00
committed by GitHub
parent 4bfec4191e
commit a1fdd56565
3 changed files with 19 additions and 19 deletions

View File

@@ -190,26 +190,26 @@ export class RbacModel {
};
/**
* 更新用户角色,使用事务保证原子性
* @param userId 用户ID
* @param roleIds 角色ID数组
* Update user roles using a transaction to ensure atomicity
* @param userId User ID
* @param roleIds Array of role IDs
*/
updateUserRoles = async (userId: string, roleIds: string[]): Promise<void> => {
// 校验角色是否存在
// Validate that the roles exist
const existingRoles = await this.db.query.roles.findMany({
where: inArray(roles.id, roleIds),
});
if (existingRoles.length !== roleIds.length) {
const missingRoleIds = roleIds.filter((id) => !existingRoles.some((r) => r.id === id));
throw new Error(`角色 ${missingRoleIds.join(', ')} 不存在`);
throw new Error(`Roles ${missingRoleIds.join(', ')} do not exist`);
}
return await this.db.transaction(async (tx) => {
// 1. 删除用户现有的所有角色
// 1. Delete all existing roles for the user
await tx.delete(userRoles).where(eq(userRoles.userId, userId));
// 2. 如果有新角色,则插入新角色
// 2. Insert new roles if any are provided
if (roleIds.length > 0) {
await tx.insert(userRoles).values(
roleIds.map((roleId) => ({

View File

@@ -47,7 +47,7 @@ const evalModes = [
] as const;
// ============================================
// 1. agent_eval_benchmarks(评测基准)
// 1. agent_eval_benchmarks (Evaluation Benchmarks)
// ============================================
export const agentEvalBenchmarks = pgTable(
'agent_eval_benchmarks',
@@ -83,7 +83,7 @@ export type NewAgentEvalBenchmark = typeof agentEvalBenchmarks.$inferInsert;
export type AgentEvalBenchmarkItem = typeof agentEvalBenchmarks.$inferSelect;
// ============================================
// 2. agent_eval_datasets(评测题集)
// 2. agent_eval_datasets (Evaluation Datasets)
// ============================================
export const agentEvalDatasets = pgTable(
'agent_eval_datasets',
@@ -121,7 +121,7 @@ export type NewAgentEvalDataset = typeof agentEvalDatasets.$inferInsert;
export type AgentEvalDatasetItem = typeof agentEvalDatasets.$inferSelect;
// ============================================
// 3. agent_eval_test_cases(评测题目)
// 3. agent_eval_test_cases (Evaluation Test Cases)
// ============================================
export const agentEvalTestCases = pgTable(
'agent_eval_test_cases',
@@ -160,7 +160,7 @@ export type NewAgentEvalTestCase = typeof agentEvalTestCases.$inferInsert;
export type AgentEvalTestCaseItem = typeof agentEvalTestCases.$inferSelect;
// ============================================
// 4. agent_eval_runs(评测运行)
// 4. agent_eval_runs (Evaluation Runs)
// ============================================
export const agentEvalRuns = pgTable(
'agent_eval_runs',
@@ -207,7 +207,7 @@ export type NewAgentEvalRun = typeof agentEvalRuns.$inferInsert;
export type AgentEvalRunItem = typeof agentEvalRuns.$inferSelect;
// ============================================
// 5. agent_eval_run_topics(评测运行与 Topic 关联表)
// 5. agent_eval_run_topics (Evaluation Run and Topic Association Table)
// ============================================
export const agentEvalRunTopics = pgTable(
'agent_eval_run_topics',

View File

@@ -14,33 +14,33 @@ export const agentSkills = pgTable(
.$defaultFn(() => idGenerator('agentSkills'))
.primaryKey(),
// 核心标识
// Core identifiers
name: text('name').notNull(),
description: text('description').notNull(),
identifier: text('identifier').notNull(),
// 来源控制
// Source control
source: text('source', { enum: ['builtin', 'market', 'user'] }).notNull(),
// Manifest (version, author, repository)
// Manifest (version, author, repository, etc.)
manifest: jsonb('manifest')
.$type<SkillManifest>()
.notNull()
.default({} as SkillManifest),
// 内容与编辑器状态
// Content and editor state
content: text('content'),
editorData: jsonb('editor_data').$type<Record<string, any>>(),
// 资源映射: Record<VirtualPath, SkillResourceMeta>
// Resource mapping: Record<VirtualPath, SkillResourceMeta>
resources: jsonb('resources').$type<Record<string, SkillResourceMeta>>().default({}),
// 原始分发包 (CAS)
// Raw distribution package (CAS)
zipFileHash: varchar('zip_file_hash', { length: 64 }).references(() => globalFiles.hashId, {
onDelete: 'set null',
}),
// 归属
// Ownership
userId: text('user_id')
.references(() => users.id, { onDelete: 'cascade' })
.notNull(),