Merge pull request #20277 from overleaf/jpa-ro-mirror-chunk

[misc] use Chunk for read-only mirror in frontend

GitOrigin-RevId: b97e520c7a63015179792542310d18f346752e92
This commit is contained in:
Jakob Ackermann
2024-09-23 13:09:01 +02:00
committed by Copybot
parent 18a052f224
commit 3ba3ffe56d
7 changed files with 285 additions and 3 deletions

View File

@@ -6,10 +6,11 @@ const OError = require('@overleaf/o-error')
const History = require('./history')
/**
* @import { BlobStore } from "./types"
* @import { BlobStore, RawChunk } from "./types"
* @import Change from "./change"
* @import Snapshot from "./snapshot"
*/
class ConflictingEndVersion extends OError {
constructor(clientEndVersion, latestEndVersion) {
const message =
@@ -84,6 +85,10 @@ class Chunk {
this.startVersion = startVersion
}
/**
* @param {RawChunk} raw
* @return {Chunk}
*/
static fromRaw(raw) {
return new Chunk(History.fromRaw(raw.history), raw.startVersion)
}

View File

@@ -76,6 +76,16 @@ export type RawSnapshot = {
v2DocVersions?: RawV2DocVersions | null
}
export type RawHistory = {
snapshot: RawSnapshot
changes: RawChange[]
}
export type RawChunk = {
history: RawHistory
startVersion: number
}
export type RawFileMap = Record<string, RawFile>
export type RawFile = { metadata?: Object } & RawFileData