(filePath: string)
| 42 | } |
| 43 | |
| 44 | export function parseSyncFromFile(filePath: string): SyncMeta | null { |
| 45 | try { |
| 46 | const isJsonl = filePath.endsWith('.jsonl') |
| 47 | if (isJsonl) { |
| 48 | const content = fs.readFileSync(filePath, 'utf-8') |
| 49 | const lines = content.trimEnd().split('\n') |
| 50 | for (let i = lines.length - 1; i >= Math.max(0, lines.length - 5); i--) { |
| 51 | try { |
| 52 | const obj = JSON.parse(lines[i]) |
| 53 | if (obj._type === 'sync') { |
| 54 | return { |
| 55 | hasMore: !!obj.hasMore, |
| 56 | nextSince: obj.nextSince, |
| 57 | nextOffset: obj.nextOffset, |
| 58 | watermark: obj.watermark, |
| 59 | } |
| 60 | } |
| 61 | } catch { |
| 62 | continue |
| 63 | } |
| 64 | } |
| 65 | return null |
| 66 | } |
| 67 | |
| 68 | const raw = fs.readFileSync(filePath, 'utf-8') |
| 69 | const parsed = JSON.parse(raw) |
| 70 | if (parsed.sync && typeof parsed.sync === 'object') { |
| 71 | const s = parsed.sync |
| 72 | return { hasMore: !!s.hasMore, nextSince: s.nextSince, nextOffset: s.nextOffset, watermark: s.watermark } |
| 73 | } |
| 74 | return null |
| 75 | } catch { |
| 76 | return null |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | function fileContainsMessages(filePath: string): boolean { |
| 81 | try { |
no test coverage detected