@allbluecn/database 0.14.9 → 0.14.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ -- P4 任务 25 一次性迁移:Harness telemetry 设置 + 上传台账(opt-in 日志上传)。
2
+ -- 由 `prisma migrate diff --from-empty --to-schema` 生成后仅保留本二模型的加法段
3
+ -- (Prisma 7 会把迁移链中的 raw 表推导为 DROP——团队既定方案不把该 DROP 写入迁移,
4
+ -- 见 packages/AGENTS.md「Prisma 7 raw 表」节与 db-migration-check.yml 白名单)。
5
+
6
+ -- CreateTable
7
+ CREATE TABLE "harness_telemetry_settings" (
8
+ "id" TEXT NOT NULL,
9
+ "userId" TEXT NOT NULL,
10
+ "countersEnabled" BOOLEAN NOT NULL DEFAULT false,
11
+ "uploadEnabled" BOOLEAN NOT NULL DEFAULT false,
12
+ "endpointUrl" TEXT,
13
+ "retentionDays" INTEGER NOT NULL DEFAULT 14,
14
+ "excludedThreadIds" JSONB NOT NULL DEFAULT '[]',
15
+ "excludedWorkspaceIds" JSONB NOT NULL DEFAULT '[]',
16
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
17
+ "updatedAt" TIMESTAMP(3) NOT NULL,
18
+
19
+ CONSTRAINT "harness_telemetry_settings_pkey" PRIMARY KEY ("id")
20
+ );
21
+
22
+ -- CreateTable
23
+ CREATE TABLE "harness_telemetry_uploads" (
24
+ "id" TEXT NOT NULL,
25
+ "userId" TEXT NOT NULL,
26
+ "endpointUrl" TEXT NOT NULL,
27
+ "endpointKind" TEXT NOT NULL,
28
+ "status" TEXT NOT NULL,
29
+ "payloadBytes" INTEGER NOT NULL,
30
+ "threadCount" INTEGER NOT NULL,
31
+ "eventCount" INTEGER NOT NULL,
32
+ "errorText" TEXT,
33
+ "uploadedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
34
+
35
+ CONSTRAINT "harness_telemetry_uploads_pkey" PRIMARY KEY ("id")
36
+ );
37
+
38
+ -- CreateIndex
39
+ CREATE UNIQUE INDEX "harness_telemetry_settings_userId_key" ON "harness_telemetry_settings"("userId");
40
+
41
+ -- CreateIndex
42
+ CREATE INDEX "harness_telemetry_uploads_userId_uploadedAt_idx" ON "harness_telemetry_uploads"("userId", "uploadedAt");
43
+
44
+ -- AddForeignKey
45
+ ALTER TABLE "harness_telemetry_settings" ADD CONSTRAINT "harness_telemetry_settings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
46
+
47
+ -- AddForeignKey
48
+ ALTER TABLE "harness_telemetry_uploads" ADD CONSTRAINT "harness_telemetry_uploads_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbluecn/database",
3
- "version": "0.14.9",
3
+ "version": "0.14.10",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/schema.prisma CHANGED
@@ -121,6 +121,12 @@ model User {
121
121
  plugins HarnessPlugin[]
122
122
  harnessWorkspaces HarnessWorkspace[]
123
123
  harnessSshHosts HarnessSshHost[]
124
+ harnessForgeBindings HarnessForgeBinding[]
125
+ harnessWorktrees HarnessWorktree[]
126
+ harnessPluginMarketSources HarnessPluginMarketSource[]
127
+ harnessPluginVersionExemptions HarnessPluginVersionExemption[]
128
+ harnessTelemetrySettings HarnessTelemetrySettings?
129
+ harnessTelemetryUploads HarnessTelemetryUpload[]
124
130
  agentBindings BusinessAgentBinding[]
125
131
  blobs Blob[]
126
132
  bugsAssigned Bug[] @relation("bugAssignee")
@@ -3589,3 +3595,140 @@ model HarnessSessionSearchToken {
3589
3595
  @@index([token])
3590
3596
  @@map("harness_session_search_tokens")
3591
3597
  }
3598
+
3599
+ /// Forge 代码托管绑定(P4 任务 17):provider 账号级绑定(github|gitlab),桌面/云端
3600
+ /// 共享(母规格 §4.5 同步白名单成员,注册 sync-core self/userId scope)。凭据明文只进
3601
+ /// CredentialStore(credentialRef = "forge:<bindingId>" 约定引用),库里零明文。
3602
+ /// scopeType/scopeName 限定绑定可见域(user 账号或 org),repoWhitelist 为可选仓库白名单。
3603
+ model HarnessForgeBinding {
3604
+ id String @id @default(cuid())
3605
+ userId String
3606
+ provider String // github | gitlab
3607
+ accountLabel String // 展示用账号标识(登录名),不敏感
3608
+ scopeType String @default("user") // user | org
3609
+ scopeName String?
3610
+ repoWhitelist Json? // ["owner/repo", ...];null = 不限
3611
+ credentialRef String // CredentialStore 引用("forge:<id>"),明文不入库
3612
+ createdAt DateTime @default(now())
3613
+ updatedAt DateTime @updatedAt
3614
+
3615
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
3616
+
3617
+ @@unique([userId, provider, accountLabel])
3618
+ @@index([userId])
3619
+ @@map("harness_forge_bindings")
3620
+ }
3621
+
3622
+ /// Harness worktree 生命周期(P4 任务 17,仅本地执行面):enter_worktree 创建并挂靠
3623
+ /// 线程(status=active),exit_worktree 三态(保留=不动 / 归档=标 archived 目录留存 /
3624
+ /// 删除=删目录删记录,必须用户授权)。设备本地状态,不注册 sync。
3625
+ model HarnessWorktree {
3626
+ id String @id @default(cuid())
3627
+ userId String
3628
+ threadId String
3629
+ path String // 相对 workspace root(".allblue-worktrees/<name>"),写入前过路径安全校验
3630
+ baseBranch String
3631
+ headBranch String
3632
+ status String @default("active") // active | merged | archived
3633
+ removedAt DateTime?
3634
+ createdAt DateTime @default(now())
3635
+ updatedAt DateTime @updatedAt
3636
+
3637
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
3638
+
3639
+ @@unique([userId, threadId, path])
3640
+ @@index([userId, status])
3641
+ @@index([threadId, status])
3642
+ @@map("harness_worktrees")
3643
+ }
3644
+
3645
+ /// 插件市场可信索引源(P4 任务 17 迁移落盘,任务 24 消费):用户自配索引 URL +
3646
+ /// 优先级;本地执行面状态,不注册 sync。
3647
+ model HarnessPluginMarketSource {
3648
+ id String @id @default(cuid())
3649
+ userId String
3650
+ name String
3651
+ url String
3652
+ enabled Boolean @default(true)
3653
+ priority Int @default(0)
3654
+ createdAt DateTime @default(now())
3655
+ updatedAt DateTime @updatedAt
3656
+
3657
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
3658
+
3659
+ @@unique([userId, name])
3660
+ @@index([userId, enabled])
3661
+ @@map("harness_plugin_market_sources")
3662
+ }
3663
+
3664
+ /// 插件版本豁免(P4 任务 17 迁移落盘,任务 24 消费):build 审批的版本范围豁免
3665
+ /// (可选过期);本地执行面状态,不注册 sync。
3666
+ model HarnessPluginVersionExemption {
3667
+ id String @id @default(cuid())
3668
+ userId String
3669
+ pluginName String
3670
+ versionRange String
3671
+ reason String @db.Text
3672
+ expiresAt DateTime?
3673
+ createdAt DateTime @default(now())
3674
+ updatedAt DateTime @updatedAt
3675
+
3676
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
3677
+
3678
+ @@unique([userId, pluginName, versionRange])
3679
+ @@index([userId, pluginName])
3680
+ @@map("harness_plugin_version_exemptions")
3681
+ }
3682
+
3683
+ /// Harness telemetry 设置(P4 任务 25):每用户一行(opt-in 日志上传 + 计数偏好 +
3684
+ /// 排除谓词 + 保留期)。匿名计数面本身由部署级 env `HARNESS_TELEMETRY` 主闸
3685
+ /// (默认关闭)与本开关共同生效;上传端点为空 → Pro 托管(harnessTelemetryUpload
3686
+ /// 门控)或不可用。本地执行面状态,不注册 sync。
3687
+ model HarnessTelemetrySettings {
3688
+ id String @id @default(cuid())
3689
+ userId String @unique
3690
+ /// 匿名计数 opt-in(env 主闸开启时才真正采集)
3691
+ countersEnabled Boolean @default(false)
3692
+ /// 日志上传 opt-in
3693
+ uploadEnabled Boolean @default(false)
3694
+ /// 用户自配上传端点(空 → Pro 托管或不可用);写入与上传时双过 SSRF 守卫
3695
+ endpointUrl String?
3696
+ /// 保留期天数(滚动清理 HarnessTelemetryUpload 台账)
3697
+ retentionDays Int @default(14)
3698
+ /// 排除线程 id 清单(JSON string[];上传收集时排除)
3699
+ excludedThreadIds Json @default("[]")
3700
+ /// 排除工作区 id 清单(JSON string[];其下全部线程排除)
3701
+ excludedWorkspaceIds Json @default("[]")
3702
+ createdAt DateTime @default(now())
3703
+ updatedAt DateTime @updatedAt
3704
+
3705
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
3706
+
3707
+ @@map("harness_telemetry_settings")
3708
+ }
3709
+
3710
+ /// Harness telemetry 上传台账(P4 任务 25):一次上传一行(载荷摘要 + 状态);
3711
+ /// 载荷本体按保留期随行滚动清理(retentionDays),保留期到期即删(含失败记录)。
3712
+ model HarnessTelemetryUpload {
3713
+ id String @id @default(cuid())
3714
+ userId String
3715
+ /// 上传目标端点(审计面;载荷已脱敏)
3716
+ endpointUrl String
3717
+ /// managed(Pro 托管)| custom(用户自配)
3718
+ endpointKind String
3719
+ /// success | failed
3720
+ status String
3721
+ /// 载荷字节数(脱敏后)
3722
+ payloadBytes Int
3723
+ /// 包含线程数 / 事件计数条数(匿名摘要,零内容)
3724
+ threadCount Int
3725
+ eventCount Int
3726
+ /// 失败原因(redactSecretsForLog 脱敏后)
3727
+ errorText String? @db.Text
3728
+ uploadedAt DateTime @default(now())
3729
+
3730
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
3731
+
3732
+ @@index([userId, uploadedAt])
3733
+ @@map("harness_telemetry_uploads")
3734
+ }