feat(mcp): подготовить сервер и доступ к приёмке
This commit is contained in:
commit
bf3d50e1ff
3835 files changed
+537122
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { emptySpeedProbeObservations, sameSpeedMeasurement, type SpeedMeasurementParameters, type SpeedProbeRead } from "@mmapp/contracts"
|
||||
type Observations = Pick<SpeedProbeRead, keyof typeof emptySpeedProbeObservations>
|
||||
type Pair = { id: string } & SpeedMeasurementParameters
|
||||
/** Publish confirmed configuration while preserving the latest snapshot only for the same measurement parameters. */
|
||||
export function publishSpeedProbeSnapshots<T extends Pair & Partial<Observations>>(previous: readonly T[], next: readonly T[]) {
|
||||
const byId = new Map(previous.map(row => [row.id, row]))
|
||||
return next.map(row => {
|
||||
const old = byId.get(row.id)
|
||||
if (!old || !sameSpeedMeasurement(old, row)) {
|
||||
return { ...row, ...emptySpeedProbeObservations }
|
||||
}
|
||||
const observations = Object.fromEntries(Object.keys(emptySpeedProbeObservations).map(key => [key, old[key as keyof Observations] ?? null])) as Observations
|
||||
return { ...row, ...observations }
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user