dify/web/features/deployments/detail/overview/environment-status/overview-drift.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

26 lines
949 B
TypeScript

import type { EnvironmentDeployment, Release } from '@dify/contracts/enterprise/types.gen'
import { isUndeployedDeploymentRow } from '../../../shared/domain/runtime-status'
export type Drift =
| { kind: 'undeployed' }
| { kind: 'unknown' }
| { kind: 'up-to-date' }
| { kind: 'behind'; steps: number }
export function computeDrift(row: EnvironmentDeployment): Drift {
if (isUndeployedDeploymentRow(row)) return { kind: 'undeployed' }
if (!row.currentRelease) return { kind: 'unknown' }
// releasesBehind is server-computed against the full release history (0 == up
// to date). It is absent only when undetermined, which renders as unknown.
const behind = row.releasesBehind
if (behind == null) return { kind: 'unknown' }
if (behind === 0) return { kind: 'up-to-date' }
return { kind: 'behind', steps: behind }
}
export function latestReleaseId(releaseRows: Release[]): string | undefined {
return releaseRows[0]?.id
}