@allbluecn/web-app 0.27.30 → 0.27.31
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/package.json
CHANGED
|
@@ -112,7 +112,7 @@ export const SDK_GROUPS: SdkGroup[] = [
|
|
|
112
112
|
"items": [
|
|
113
113
|
{
|
|
114
114
|
"name": "@allbluecn/web-app",
|
|
115
|
-
"version": "v0.27.
|
|
115
|
+
"version": "v0.27.31",
|
|
116
116
|
"lastUpdate": "Nov 10, 2026",
|
|
117
117
|
"source": "apps/web/package.json",
|
|
118
118
|
"docsUrl": "https://github.com/allbluecn/allblue"
|
|
@@ -128,16 +128,28 @@ export function messageStore(userId: string): MessageStore {
|
|
|
128
128
|
createdAt: new Date(Date.now() + idx),
|
|
129
129
|
})) as unknown as Prisma.ChatMessageCreateManyInput[];
|
|
130
130
|
|
|
131
|
+
// harness durability 在 terminal event 后重放可能投递重复 id 消息(真机
|
|
132
|
+
// 实测 ChatMessage.createMany P2002/23505 chat_messages_pkey)——按 id 保序
|
|
133
|
+
// 去重(先出现优先)。占位主键(无 id 消息)由 generateId 保证唯一。
|
|
134
|
+
const seenIds = new Set<string>();
|
|
135
|
+
const dedupedData = data.filter((row) => {
|
|
136
|
+
const id = row.id as string | undefined
|
|
137
|
+
if (id === undefined) return true // 占位主键恒唯一,不去重
|
|
138
|
+
if (seenIds.has(id)) return false;
|
|
139
|
+
seenIds.add(id);
|
|
140
|
+
return true;
|
|
141
|
+
});
|
|
142
|
+
|
|
131
143
|
// 事务化(审计 2026-10-25 A3x-2 🟡):deleteMany 与 createMany 两步写之间
|
|
132
144
|
// 进程崩溃 / DB 抖动会让旧消息已删、新消息未写——线程历史全失。数组形式
|
|
133
145
|
// $transaction 全或无;空消息数组只保留 delete 步骤(createMany 空数组
|
|
134
|
-
// 会被 Prisma 校验拒绝)。
|
|
146
|
+
// 会被 Prisma 校验拒绝)。skipDuplicates 双保险(输入数组内重复 + 残留)。
|
|
135
147
|
await prisma.$transaction([
|
|
136
148
|
prisma.chatMessage.deleteMany({
|
|
137
149
|
where: { threadId, thread: { userId } },
|
|
138
150
|
}),
|
|
139
|
-
...(
|
|
140
|
-
? [prisma.chatMessage.createMany({ data })]
|
|
151
|
+
...(dedupedData.length > 0
|
|
152
|
+
? [prisma.chatMessage.createMany({ data: dedupedData, skipDuplicates: true })]
|
|
141
153
|
: []),
|
|
142
154
|
]);
|
|
143
155
|
|