* Parse a stored last-completed marker, rebuilding it from validated fields so a * stale or wrong-shaped Redis value can never reach API consumers.
(raw: string | undefined)
| 185 | * stale or wrong-shaped Redis value can never reach API consumers. |
| 186 | */ |
| 187 | function parseCompletedMarker(raw: string | undefined): ExecutionLastCompletedBlock | undefined { |
| 188 | const v = safeJsonParse(raw) |
| 189 | if (!isRecord(v)) return undefined |
| 190 | const { blockId, blockName, blockType, endedAt, success } = v |
| 191 | if ( |
| 192 | typeof blockId === 'string' && |
| 193 | typeof blockName === 'string' && |
| 194 | typeof blockType === 'string' && |
| 195 | typeof endedAt === 'string' && |
| 196 | typeof success === 'boolean' |
| 197 | ) { |
| 198 | return { blockId, blockName, blockType, endedAt, success } |
| 199 | } |
| 200 | return undefined |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Read both markers for an execution. Returns an empty object when Redis is |
no test coverage detected