diff --git a/services/document-updater/app/js/DocumentManager.js b/services/document-updater/app/js/DocumentManager.js index 2ff31b8c41..4803056423 100644 --- a/services/document-updater/app/js/DocumentManager.js +++ b/services/document-updater/app/js/DocumentManager.js @@ -176,7 +176,7 @@ const DocumentManager = { } // Circular dependencies. Import at runtime. - const HistoryV1OTUpdateManager = require('./HistoryV1OTUpdateManager') + const HistoryOTUpdateManager = require('./HistoryOTUpdateManager') const UpdateManager = require('./UpdateManager') const { @@ -246,7 +246,7 @@ const DocumentManager = { // removed from redis. if (op.length > 0) { if (type === 'history-ot') { - await HistoryV1OTUpdateManager.applyUpdate(projectId, docId, update) + await HistoryOTUpdateManager.applyUpdate(projectId, docId, update) } else { await UpdateManager.promises.applyUpdate(projectId, docId, update) } diff --git a/services/document-updater/app/js/HistoryV1OTUpdateManager.js b/services/document-updater/app/js/HistoryOTUpdateManager.js similarity index 94% rename from services/document-updater/app/js/HistoryV1OTUpdateManager.js rename to services/document-updater/app/js/HistoryOTUpdateManager.js index ca3183ec62..5a8b92099e 100644 --- a/services/document-updater/app/js/HistoryV1OTUpdateManager.js +++ b/services/document-updater/app/js/HistoryOTUpdateManager.js @@ -16,12 +16,12 @@ const RealTimeRedisManager = require('./RealTimeRedisManager') /** * @typedef {import("./types").Update} Update - * @typedef {import("./types").HistoryV1OTEditOperationUpdate} HistoryV1OTEditOperationUpdate + * @typedef {import("./types").HistoryOTEditOperationUpdate} HistoryOTEditOperationUpdate */ /** * @param {Update} update - * @return {update is HistoryV1OTEditOperationUpdate} + * @return {update is HistoryOTEditOperationUpdate} */ function isHistoryOTEditOperationUpdate(update) { return ( @@ -39,7 +39,7 @@ function isHistoryOTEditOperationUpdate(update) { * * @param {string} projectId * @param {string} docId - * @param {HistoryV1OTEditOperationUpdate} update + * @param {HistoryOTEditOperationUpdate} update * @param {Profiler} profiler */ async function tryApplyUpdate(projectId, docId, update, profiler) { @@ -131,7 +131,7 @@ async function tryApplyUpdate(projectId, docId, update, profiler) { * * @param {string} projectId * @param {string} docId - * @param {HistoryV1OTEditOperationUpdate} update + * @param {HistoryOTEditOperationUpdate} update */ async function applyUpdate(projectId, docId, update) { const profiler = new Profiler('applyUpdate', { diff --git a/services/document-updater/app/js/HttpController.js b/services/document-updater/app/js/HttpController.js index 2a7a40d8b5..0a6ae3b2b4 100644 --- a/services/document-updater/app/js/HttpController.js +++ b/services/document-updater/app/js/HttpController.js @@ -37,7 +37,7 @@ function getDoc(req, res, next) { if (lines == null || version == null) { return next(new Errors.NotFoundError('document not found')) } - if (!Array.isArray(lines) && req.query.historyV1OTSupport !== 'true') { + if (!Array.isArray(lines) && req.query.historyOTSupport !== 'true') { const file = StringFileData.fromRaw(lines) // TODO(24596): tc support for history-ot lines = file.getLines() @@ -91,7 +91,7 @@ function peekDoc(req, res, next) { if (lines == null || version == null) { return next(new Errors.NotFoundError('document not found')) } - if (!Array.isArray(lines) && req.query.historyV1OTSupport !== 'true') { + if (!Array.isArray(lines) && req.query.historyOTSupport !== 'true') { const file = StringFileData.fromRaw(lines) // TODO(24596): tc support for history-ot lines = file.getLines() diff --git a/services/document-updater/app/js/UpdateManager.js b/services/document-updater/app/js/UpdateManager.js index ba37018a14..e5df48575e 100644 --- a/services/document-updater/app/js/UpdateManager.js +++ b/services/document-updater/app/js/UpdateManager.js @@ -15,7 +15,7 @@ const RangesManager = require('./RangesManager') const SnapshotManager = require('./SnapshotManager') const Profiler = require('./Profiler') const { isInsert, isDelete, getDocLength, computeDocHash } = require('./Utils') -const HistoryV1OTUpdateManager = require('./HistoryV1OTUpdateManager') +const HistoryOTUpdateManager = require('./HistoryOTUpdateManager') /** * @import { Ranges, Update, HistoryUpdate } from "./types" @@ -81,8 +81,8 @@ const UpdateManager = { profile.log('getPendingUpdatesForDoc') for (const update of updates) { - if (HistoryV1OTUpdateManager.isHistoryOTEditOperationUpdate(update)) { - await HistoryV1OTUpdateManager.applyUpdate(projectId, docId, update) + if (HistoryOTUpdateManager.isHistoryOTEditOperationUpdate(update)) { + await HistoryOTUpdateManager.applyUpdate(projectId, docId, update) } else { await UpdateManager.applyUpdate(projectId, docId, update) } diff --git a/services/document-updater/app/js/types.ts b/services/document-updater/app/js/types.ts index d630e7fc82..851e62d8c8 100644 --- a/services/document-updater/app/js/types.ts +++ b/services/document-updater/app/js/types.ts @@ -23,7 +23,7 @@ export type Update = { projectHistoryId?: string } -export type HistoryV1OTEditOperationUpdate = Omit & { +export type HistoryOTEditOperationUpdate = Omit & { op: RawEditOperation[] meta: Update['meta'] & { source: string } } diff --git a/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js b/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js index 32a94f37cb..39ec6c2ac7 100644 --- a/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js +++ b/services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js @@ -31,7 +31,7 @@ describe('Applying updates to a doc', function () { op: [this.op], v: this.version, } - this.historyV1OTUpdate = { + this.historyOTUpdate = { doc: this.doc_id, op: [{ textOperation: [4, 'one and a half\n', 9] }], v: this.version, @@ -301,7 +301,7 @@ describe('Applying updates to a doc', function () { DocUpdaterClient.sendUpdate( this.project_id, this.doc_id, - this.historyV1OTUpdate, + this.historyOTUpdate, error => { if (error != null) { throw error @@ -352,7 +352,7 @@ describe('Applying updates to a doc', function () { if (error != null) { throw error } - JSON.parse(updates[0]).op.should.deep.equal(this.historyV1OTUpdate.op) + JSON.parse(updates[0]).op.should.deep.equal(this.historyOTUpdate.op) JSON.parse(updates[0]).meta.pathname.should.equal('/a/b/c.tex') done() @@ -395,7 +395,7 @@ describe('Applying updates to a doc', function () { describe('when sending another update', function () { beforeEach(function (done) { this.timeout(10000) - this.second_update = Object.assign({}, this.historyV1OTUpdate) + this.second_update = Object.assign({}, this.historyOTUpdate) this.second_update.op = [ { textOperation: [4, 'one and a half\n', 24], @@ -664,7 +664,7 @@ describe('Applying updates to a doc', function () { DocUpdaterClient.sendUpdate( this.project_id, this.doc_id, - this.historyV1OTUpdate, + this.historyOTUpdate, error => { if (error != null) { throw error @@ -694,7 +694,7 @@ describe('Applying updates to a doc', function () { -1, (error, updates) => { if (error) return done(error) - JSON.parse(updates[0]).op.should.deep.equal(this.historyV1OTUpdate.op) + JSON.parse(updates[0]).op.should.deep.equal(this.historyOTUpdate.op) JSON.parse(updates[0]).meta.pathname.should.equal('/a/b/c.tex') done() } @@ -979,7 +979,7 @@ describe('Applying updates to a doc', function () { DocUpdaterClient.sendUpdate( this.project_id, this.doc_id, - this.historyV1OTUpdate, + this.historyOTUpdate, error => { if (error != null) { throw error diff --git a/services/document-updater/test/acceptance/js/SettingADocumentTests.js b/services/document-updater/test/acceptance/js/SettingADocumentTests.js index 83e662185a..fd1851a221 100644 --- a/services/document-updater/test/acceptance/js/SettingADocumentTests.js +++ b/services/document-updater/test/acceptance/js/SettingADocumentTests.js @@ -201,7 +201,7 @@ describe('Setting a document', function () { numberOfReceivedUpdates = 0 this.project_id = DocUpdaterClient.randomId() this.doc_id = DocUpdaterClient.randomId() - this.historyV1OTUpdate = { + this.historyOTUpdate = { doc: this.doc_id, op: [{ textOperation: [4, 'one and a half\n', 9] }], v: this.version, @@ -219,7 +219,7 @@ describe('Setting a document', function () { DocUpdaterClient.sendUpdate( this.project_id, this.doc_id, - this.historyV1OTUpdate, + this.historyOTUpdate, error => { if (error) { throw error diff --git a/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js b/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js index f0effb4c24..1816579103 100644 --- a/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js +++ b/services/document-updater/test/unit/js/DocumentManager/DocumentManagerTests.js @@ -49,7 +49,7 @@ describe('DocumentManager', function () { applyUpdate: sinon.stub().resolves(), }, } - this.HistoryV1OTUpdateManager = { + this.HistoryOTUpdateManager = { applyUpdate: sinon.stub().resolves(), } this.RangesManager = { @@ -69,7 +69,7 @@ describe('DocumentManager', function () { './Metrics': this.Metrics, './DiffCodec': this.DiffCodec, './UpdateManager': this.UpdateManager, - './HistoryV1OTUpdateManager': this.HistoryV1OTUpdateManager, + './HistoryOTUpdateManager': this.HistoryOTUpdateManager, './RangesManager': this.RangesManager, './Errors': Errors, '@overleaf/settings': this.Settings, diff --git a/services/project-history/app/js/UpdateCompressor.js b/services/project-history/app/js/UpdateCompressor.js index 726cb5fff9..471fc791ab 100644 --- a/services/project-history/app/js/UpdateCompressor.js +++ b/services/project-history/app/js/UpdateCompressor.js @@ -231,11 +231,9 @@ function _concatTwoUpdates(firstUpdate, secondUpdate) { return [firstUpdate, secondUpdate] } - const firstUpdateIsHistoryV1OT = EditOperationBuilder.isValid(firstUpdate.op) - const secondUpdateIsHistoryV1OT = EditOperationBuilder.isValid( - secondUpdate.op - ) - if (firstUpdateIsHistoryV1OT !== secondUpdateIsHistoryV1OT) { + const firstUpdateIsHistoryOT = EditOperationBuilder.isValid(firstUpdate.op) + const secondUpdateIsHistoryOT = EditOperationBuilder.isValid(secondUpdate.op) + if (firstUpdateIsHistoryOT !== secondUpdateIsHistoryOT) { // cannot merge mix of sharejs-text-op and history-ot, should not happen. return [firstUpdate, secondUpdate] } @@ -286,7 +284,7 @@ function _concatTwoUpdates(firstUpdate, secondUpdate) { return [firstUpdate, secondUpdate] } - if (firstUpdateIsHistoryV1OT && secondUpdateIsHistoryV1OT) { + if (firstUpdateIsHistoryOT && secondUpdateIsHistoryOT) { const op1 = EditOperationBuilder.fromJSON(firstUpdate.op) const op2 = EditOperationBuilder.fromJSON(secondUpdate.op) if (!op1.canBeComposedWith(op2)) return [firstUpdate, secondUpdate] diff --git a/services/project-history/app/js/UpdateTranslator.js b/services/project-history/app/js/UpdateTranslator.js index c1443ab1cd..43b9f48270 100644 --- a/services/project-history/app/js/UpdateTranslator.js +++ b/services/project-history/app/js/UpdateTranslator.js @@ -7,7 +7,7 @@ import * as OperationsCompressor from './OperationsCompressor.js' import { isInsert, isRetain, isDelete, isComment } from './Utils.js' /** - * @import { AddDocUpdate, AddFileUpdate, DeleteCommentUpdate, HistoryV1OTEditOperationUpdate, Op, RawScanOp } from './types' + * @import { AddDocUpdate, AddFileUpdate, DeleteCommentUpdate, HistoryOTEditOperationUpdate, Op, RawScanOp } from './types' * @import { RenameUpdate, TextUpdate, TrackingDirective, TrackingProps } from './types' * @import { SetCommentStateUpdate, SetFileMetadataOperation, Update, UpdateWithBlob } from './types' */ @@ -206,7 +206,7 @@ export function isTextUpdate(update) { /** * @param {Update} update - * @returns {update is HistoryV1OTEditOperationUpdate} + * @returns {update is HistoryOTEditOperationUpdate} */ export function isHistoryOTEditOperationUpdate(update) { return ( diff --git a/services/project-history/app/js/types.ts b/services/project-history/app/js/types.ts index 23911b0086..96701e587f 100644 --- a/services/project-history/app/js/types.ts +++ b/services/project-history/app/js/types.ts @@ -44,7 +44,7 @@ export type TextUpdate = { } } -export type HistoryV1OTEditOperationUpdate = { +export type HistoryOTEditOperationUpdate = { doc: string op: RawEditOperation[] v: number diff --git a/services/real-time/app/js/DocumentUpdaterManager.js b/services/real-time/app/js/DocumentUpdaterManager.js index 72a37d0f1d..51b71e8ec0 100644 --- a/services/real-time/app/js/DocumentUpdaterManager.js +++ b/services/real-time/app/js/DocumentUpdaterManager.js @@ -19,7 +19,7 @@ const Keys = settings.redis.documentupdater.key_schema const DocumentUpdaterManager = { getDocument(projectId, docId, fromVersion, callback) { const timer = new metrics.Timer('get-document') - const url = `${settings.apis.documentupdater.url}/project/${projectId}/doc/${docId}?fromVersion=${fromVersion}&historyV1OTSupport=true` + const url = `${settings.apis.documentupdater.url}/project/${projectId}/doc/${docId}?fromVersion=${fromVersion}&historyOTSupport=true` logger.debug( { projectId, docId, fromVersion }, 'getting doc from document updater' diff --git a/services/real-time/app/js/WebsocketController.js b/services/real-time/app/js/WebsocketController.js index 17186eb92e..c0f465a490 100644 --- a/services/real-time/app/js/WebsocketController.js +++ b/services/real-time/app/js/WebsocketController.js @@ -309,11 +309,11 @@ module.exports = WebsocketController = { const encodeForWebsockets = text => unescape(encodeURIComponent(text)) metrics.inc('client_supports_history_v1_ot', 1, { - status: options.supportsHistoryV1OT ? 'success' : 'failure', + status: options.supportsHistoryOT ? 'success' : 'failure', }) let escapedLines if (type === 'history-ot') { - if (!options.supportsHistoryV1OT) { + if (!options.supportsHistoryOT) { RoomManager.leaveDoc(client, docId) // TODO(24596): ask the user to reload the editor page (via out-of-sync modal when there are pending ops). return callback( diff --git a/services/real-time/test/acceptance/js/JoinDocTests.js b/services/real-time/test/acceptance/js/JoinDocTests.js index cdb5489ec9..3381526c59 100644 --- a/services/real-time/test/acceptance/js/JoinDocTests.js +++ b/services/real-time/test/acceptance/js/JoinDocTests.js @@ -641,7 +641,7 @@ describe('joinDoc', function () { this.client.emit( 'joinDoc', this.doc_id, - { supportsHistoryV1OT: true }, + { supportsHistoryOT: true }, (error, ...rest) => { ;[...this.returnedArgs] = Array.from(rest) cb(error) diff --git a/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js b/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js index d9755fef57..ecf45cd452 100644 --- a/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js +++ b/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js @@ -79,7 +79,7 @@ describe('DocumentUpdaterManager', function () { }) it('should get the document from the document updater', function () { - const url = `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}?fromVersion=${this.fromVersion}&historyV1OTSupport=true` + const url = `${this.settings.apis.documentupdater.url}/project/${this.project_id}/doc/${this.doc_id}?fromVersion=${this.fromVersion}&historyOTSupport=true` return this.request.get.calledWith(url).should.equal(true) }) diff --git a/services/web/frontend/js/features/ide-react/editor/document-container.ts b/services/web/frontend/js/features/ide-react/editor/document-container.ts index 1770894584..fee359f146 100644 --- a/services/web/frontend/js/features/ide-react/editor/document-container.ts +++ b/services/web/frontend/js/features/ide-react/editor/document-container.ts @@ -451,7 +451,7 @@ export class DocumentContainer extends EventEmitter { { encodeRanges: true, age: this.doc.getTimeSinceLastServerActivity(), - supportsHistoryV1OT: true, + supportsHistoryOT: true, }, ( error, @@ -487,7 +487,7 @@ export class DocumentContainer extends EventEmitter { this.doc_id, { encodeRanges: true, - supportsHistoryV1OT: true, + supportsHistoryOT: true, }, ( error,