(streamId: string)
| 202 | } |
| 203 | |
| 204 | export async function getOldestSeq(streamId: string): Promise<number | null> { |
| 205 | return withRedisRetry({ operation: 'get_oldest_seq', streamId }, async (redis) => { |
| 206 | const entries = await redis.zrangebyscore(getEventsKey(streamId), '-inf', '+inf', 'LIMIT', 0, 1) |
| 207 | if (!entries || entries.length === 0) { |
| 208 | return null |
| 209 | } |
| 210 | try { |
| 211 | const parsed = JSON.parse(entries[0]) as { seq?: number } |
| 212 | return typeof parsed.seq === 'number' ? parsed.seq : null |
| 213 | } catch { |
| 214 | logger.warn('Failed to parse oldest outbox entry', { streamId }) |
| 215 | return null |
| 216 | } |
| 217 | }) |
| 218 | } |
| 219 | |
| 220 | export async function getLatestSeq(streamId: string): Promise<number | null> { |
| 221 | return withRedisRetry({ operation: 'get_latest_seq', streamId }, async (redis) => { |
no test coverage detected