27 lines
607 B
TypeScript
27 lines
607 B
TypeScript
export function normalizeStatus(raw: string | null | undefined): string {
|
|
if (typeof raw !== 'string') {
|
|
return ''
|
|
}
|
|
const trimmed = raw.trim()
|
|
if (!trimmed) {
|
|
return ''
|
|
}
|
|
return trimmed.toUpperCase().replace(/[\s-]+/g, '_')
|
|
}
|
|
|
|
export function isTerminalStatus(
|
|
status: string | null | undefined,
|
|
extras?: string[],
|
|
): boolean {
|
|
const normalized = normalizeStatus(status)
|
|
if (!normalized) {
|
|
return false
|
|
}
|
|
const terminalSet = new Set([
|
|
'SUCCESS',
|
|
'FAILED',
|
|
...(extras ?? []).map((extra) => normalizeStatus(extra)),
|
|
])
|
|
return terminalSet.has(normalized)
|
|
}
|