(input: { after?: ChangeCursor; ignore?: string[] })
| 163 | } |
| 164 | |
| 165 | async fetchChanges(input: { after?: ChangeCursor; ignore?: string[] }): Promise<{ |
| 166 | currentCursor: ChangeCursor; |
| 167 | appliedPushCursor: ChangeCursor; |
| 168 | stream: ReadableStream<ChangeEntry>; |
| 169 | }> { |
| 170 | if (this.options.beforeFetch !== undefined) { |
| 171 | try { |
| 172 | await this.options.beforeFetch(); |
| 173 | } catch (err) { |
| 174 | // Settle hook failures must not surface as fetch failures — |
| 175 | // we still want to stream whatever's already in the store. |
| 176 | // Log so the operator notices a wedged shim, then carry on. |
| 177 | console.warn("[SyncRPCServer] beforeFetch hook failed:", err); |
| 178 | } |
| 179 | } |
| 180 | const after = input.after ?? { rev: 0, path: null }; |
| 181 | const ignore = |
| 182 | input.ignore ?? (this.options.ignore.length > 0 ? this.options.ignore : DEFAULT_IGNORE); |
| 183 | const snapshotRev = currentRev(this.db); |
| 184 | const currentCursor = { rev: snapshotRev, path: null }; |
| 185 | return { |
| 186 | currentCursor, |
| 187 | appliedPushCursor: readFetchCursor(this.db), |
| 188 | stream: iterableToReadableStream( |
| 189 | coalesceChanges(this.db, after, { ignore, through: currentCursor }), |
| 190 | ), |
| 191 | }; |
| 192 | } |
| 193 | |
| 194 | async readEntry(path: string): Promise<ChangeEntry | null> { |
| 195 | return materialiseChange(this.db, path); |
nothing calls this directly
no test coverage detected