fix(api): сохранить последние снимки сертификатов

This commit is contained in:
Denozordec committed 2026-10-01 11:23:45 +07:00
1 parent 26869632a0
commit c7b4981dff
5 files changed
+67 -1

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
import type {CertificatesState,CertificateServerState} from "@mmapp/contracts/certificates"
export type CertificateSnapshot = { latest: CertificateServerState; confirmed: CertificateServerState | null }
export type CertificateSnapshots = Record<string, CertificateSnapshot>
/** Replace the enabled-device inventory; retain each failed device's last confirmed snapshot. */
export function mergeCertificateSnapshots(previous:CertificateSnapshots,result:CertificatesState):CertificateSnapshots {
return Object.fromEntries(result.servers.map(node=>[node.serverId,{
latest:node,
confirmed:node.error===null?node:previous[node.serverId]?.confirmed??null,
}]))
}