@allbluecn/database 0.14.15 → 0.14.17
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.
- package/generated/internal/class.ts +4 -4
- package/generated/internal/prismaNamespace.ts +5 -1
- package/generated/internal/prismaNamespaceBrowser.ts +5 -1
- package/generated/models/ChatThread.ts +145 -1
- package/generated/models/HarnessWorkspace.ts +231 -2
- package/generated/models/User.ts +373 -1
- package/generated/models/Workspace.ts +212 -0
- package/migrations/20261130000000_add_harness_permission/migration.sql +2 -0
- package/migrations/20261204000000_add_user_ai_search_provider_id/migration.sql +2 -0
- package/migrations/20261204225136_harness_workspace_product_binding/migration.sql +15 -0
- package/package.json +4 -3
- package/schema.prisma +11 -1
- package/scripts/patch-workerd-wasm.mjs +70 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allbluecn/database",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.17",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
7
7
|
"types": "./index.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@allbluecn/kernel": "0.12.
|
|
9
|
+
"@allbluecn/kernel": "0.12.5",
|
|
10
10
|
"@electric-sql/pglite": "0.5.13",
|
|
11
11
|
"@electric-sql/pglite-pgvector": "0.0.14",
|
|
12
12
|
"@prisma/adapter-pg": "7.8.0",
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"pglite-seed.ts",
|
|
52
52
|
"index.ts",
|
|
53
53
|
"get-prisma.ts",
|
|
54
|
-
"pg-client.ts"
|
|
54
|
+
"pg-client.ts",
|
|
55
|
+
"scripts"
|
|
55
56
|
],
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public"
|
package/schema.prisma
CHANGED
|
@@ -47,6 +47,7 @@ model User {
|
|
|
47
47
|
aiApiKey String? // 用户 AI API Key(TODO: 加密存储)
|
|
48
48
|
aiModel String? // 默认 "openai/gpt-4o-mini"
|
|
49
49
|
aiSourceMode String? // 模型来源模式:hosted | local-agent | byok;null = 未选择(默认 byok 行为)
|
|
50
|
+
aiSearchProviderId String? // 联网搜索服务商(AiProviderConfig.providerId);null = 自动选择
|
|
50
51
|
locale String? // 用户语言偏好(zh / en),null 表示未设置
|
|
51
52
|
|
|
52
53
|
storyDisplayOptions Json? // Story Display Options 个人偏好(URL 无参数时的默认值,跨设备持久化)
|
|
@@ -252,6 +253,7 @@ model Workspace {
|
|
|
252
253
|
customRoles CustomRole[]
|
|
253
254
|
auditLogs AuditLog[]
|
|
254
255
|
aiTasks AiTask[]
|
|
256
|
+
harnessWorkspaces HarnessWorkspace[]
|
|
255
257
|
|
|
256
258
|
@@index([ownerId])
|
|
257
259
|
@@map("workspaces")
|
|
@@ -358,6 +360,8 @@ model ChatThread {
|
|
|
358
360
|
title String?
|
|
359
361
|
isArchived Boolean @default(false)
|
|
360
362
|
sandboxPolicy String @default("readonly")
|
|
363
|
+
harnessPermission String @default("ask")
|
|
364
|
+
harnessPermissionVersion Int @default(0)
|
|
361
365
|
createdAt DateTime @default(now())
|
|
362
366
|
updatedAt DateTime @updatedAt
|
|
363
367
|
|
|
@@ -2562,16 +2566,22 @@ model HarnessWorkspace {
|
|
|
2562
2566
|
ownerId String
|
|
2563
2567
|
kind String @default("cloud") // "cloud" | "local-meta"(本地挂载只存元数据)
|
|
2564
2568
|
// 本地优先:本地目录映射与按需上云(v3 设计 §2.2)。三列均可空,老数据零迁移。
|
|
2565
|
-
localPath String? //
|
|
2569
|
+
localPath String? // local-meta:用户登记的本地目录;已绑定的 cloud 行:创建时自动建立的工作目录(FS realpath 规范化)
|
|
2566
2570
|
cloudOfId String? // local-meta 行指向其云端镜像 cloud 行(P4 按需上云建立;自环禁止)
|
|
2567
2571
|
lastSyncedAt DateTime? // 最近一次上云快照时间(映射态展示)
|
|
2568
2572
|
createdAt DateTime @default(now())
|
|
2569
2573
|
updatedAt DateTime @updatedAt
|
|
2570
2574
|
|
|
2575
|
+
/// 绑定的产品工作空间(/workspaces);null = 未绑定(全量内容)
|
|
2576
|
+
workspaceId String?
|
|
2577
|
+
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
2578
|
+
|
|
2571
2579
|
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
|
2572
2580
|
files WorkspaceFile[]
|
|
2573
2581
|
threads ChatThread[]
|
|
2574
2582
|
|
|
2583
|
+
@@unique([ownerId, workspaceId])
|
|
2584
|
+
@@index([workspaceId])
|
|
2575
2585
|
@@index([ownerId, updatedAt])
|
|
2576
2586
|
@@map("harness_workspaces")
|
|
2577
2587
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Prisma 7 在 Cloudflare Workers 上的 WASM 变通(prisma/orm#28657 未修):
|
|
2
|
+
// workerd 禁止动态 WASM 编译(new WebAssembly.Module(bytes) 抛
|
|
3
|
+
// "Wasm code generation disallowed by embedder"),而生成的
|
|
4
|
+
// internal/class.ts 默认对 base64 内联 wasm 运行时解码。
|
|
5
|
+
//
|
|
6
|
+
// 本脚本在 `prisma generate` 之后运行(package.json generate 链):
|
|
7
|
+
// 1. 把 @prisma/client/runtime/*.wasm-base64.mjs 的内联 wasm 解码为
|
|
8
|
+
// generated/prisma-query-compiler.postgresql.wasm 真实文件;
|
|
9
|
+
// 2. 给 getQueryCompilerWasmModule 加双路径:workerd(navigator.userAgent
|
|
10
|
+
// === "Cloudflare-Workers",官方检测口径)走 wasm 模块导入(@cloudflare/
|
|
11
|
+
// vite-plugin 构建期处理为 WasmModule,无需动态编译);Node/Vercel/desktop
|
|
12
|
+
// 保持 base64 原路,行为不变。
|
|
13
|
+
//
|
|
14
|
+
// 幂等:patch 标记存在即跳过。generated/ 为生成产物,重新 generate 后须重跑
|
|
15
|
+
// (已挂进 generate 脚本链)。
|
|
16
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const pkgDir = join(here, "..");
|
|
22
|
+
const classFile = join(pkgDir, "generated", "internal", "class.ts");
|
|
23
|
+
const wasmFile = join(pkgDir, "generated", "prisma-query-compiler.postgresql.wasm");
|
|
24
|
+
|
|
25
|
+
const MARKER = "PRISMA_WORKERD_WASM_PATCH_V1";
|
|
26
|
+
let code = readFileSync(classFile, "utf8");
|
|
27
|
+
if (code.includes(MARKER)) {
|
|
28
|
+
console.log("[patch-workerd-wasm] already patched, skip");
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const base64Module = "@prisma/client/runtime/query_compiler_fast_bg.postgresql.wasm-base64.mjs";
|
|
33
|
+
const importRe = new RegExp(
|
|
34
|
+
String.raw`const \{ wasm \} = await import\("${base64Module.replace(/[./]/g, "\\$&")}"\)\s*;?\s*return await decodeBase64AsWasm\(wasm\)`,
|
|
35
|
+
);
|
|
36
|
+
if (!importRe.test(code)) {
|
|
37
|
+
console.error("[patch-workerd-wasm] 未找到预期的 base64 加载块——生成器输出结构可能已变更,请人工核对");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 解码 wasm 文件(从内联模块读取 base64 常量;包内 node_modules symlink 直达)
|
|
42
|
+
const base64ModulePath = join(
|
|
43
|
+
pkgDir,
|
|
44
|
+
"node_modules",
|
|
45
|
+
"@prisma/client/runtime/query_compiler_fast_bg.postgresql.wasm-base64.mjs",
|
|
46
|
+
);
|
|
47
|
+
const base64Src = readFileSync(base64ModulePath, "utf8").match(
|
|
48
|
+
/"([A-Za-z0-9+/=]{100,})"/,
|
|
49
|
+
);
|
|
50
|
+
if (!base64Src) {
|
|
51
|
+
throw new Error("未能从 wasm-base64 模块中提取 base64 常量");
|
|
52
|
+
}
|
|
53
|
+
writeFileSync(wasmFile, Buffer.from(base64Src[1], "base64"));
|
|
54
|
+
|
|
55
|
+
const patched = code.replace(
|
|
56
|
+
importRe,
|
|
57
|
+
[
|
|
58
|
+
`// ${MARKER}: workerd 禁动态 WASM 编译(prisma/orm#28657),`,
|
|
59
|
+
`// Cloudflare-Workers 环境走 vite-plugin 处理的 wasm 模块导入;`,
|
|
60
|
+
`// Node/Vercel/desktop 保持 base64 原路(decodeBase64AsWasm)。`,
|
|
61
|
+
`if (typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") {`,
|
|
62
|
+
` const wasmNs = (await import("../prisma-query-compiler.postgresql.wasm")) as unknown as { default: WebAssembly.Module };`,
|
|
63
|
+
` return wasmNs.default ?? (wasmNs as unknown as WebAssembly.Module);`,
|
|
64
|
+
`}`,
|
|
65
|
+
`const { wasm } = await import("${base64Module}");`,
|
|
66
|
+
`return await decodeBase64AsWasm(wasm)`,
|
|
67
|
+
].join("\n"),
|
|
68
|
+
);
|
|
69
|
+
writeFileSync(classFile, patched);
|
|
70
|
+
console.log("[patch-workerd-wasm] patched + wasm extracted:", wasmFile);
|