feat: 收口模板升级与阶段七持续回归

This commit is contained in:
que01 committed 2026-10-17 21:33:57 +08:00
1 parent ec16fff70e
commit 71c528de34
29 files changed
+1962 -304

No files matched your search

@@ -0,0 +1,35 @@
import { HttpException } from "@nestjs/common";
import { PrismaService } from "../../prisma.service.js";
export async function recordTemplateOperationFailure(
prisma: PrismaService,
input: {
action: string;
error: unknown;
requestId?: string;
actorId?: string;
brandId?: string;
packageKey?: string;
version?: string;
},
): Promise<void> {
const status = input.error instanceof HttpException ? input.error.getStatus() : 500;
try {
await prisma.templateOperationFailureEvent.create({
data: {
action: input.action,
resultCode: `HTTP_${status}`,
...(input.requestId ? { requestId: input.requestId } : {}),
...(input.actorId ? { actorId: input.actorId } : {}),
...(input.brandId ? { brandId: input.brandId } : {}),
...(input.packageKey ? { packageKey: input.packageKey } : {}),
...(input.version ? { version: input.version } : {}),
},
});
await prisma.templateOperationFailureEvent.deleteMany({
where: { createdAt: { lt: new Date(Date.now() - 180 * 24 * 60 * 60 * 1000) } },
});
} catch {
// Failure telemetry must never replace the operation's original result.
}
}