Open History to see the last commit
1import type { Envelope } from '@neon/realtime-electric-protocol'
2import { IndexedJsonLog, shapeLogCodec, type LogRead } from './shape-log.js'
3export type { LogBoundary, LogRead } from './shape-log.js'
4
5/** All record bytes remain resident; the shared index owns offset semantics. */
6export class MemoryJsonLog<T> extends IndexedJsonLog<T> {
7 read(offset: string, limit?: number): LogRead<T> {
8 const { entries, index: _, ...metadata } = this.select(offset, limit)
9 return {
10 ...metadata,
11 envelopes: entries.map((entry) => {
12 const value = this.codec.parse(JSON.parse(entry.encoded!))
13 this.codec.validateRead(value, entry.boundary)
14 return value
15 }),
16 }
17 }
18}
19export class MemoryShapeLog extends MemoryJsonLog<Envelope> {
20 constructor() {
21 super(shapeLogCodec)
22 }
23}