mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #29948 from overleaf/ar/docstore-conversion-to-esm
[docstore] conversion to esm GitOrigin-RevId: 9d255047bd7ae25f2b0b38f3a721741e8a0b7ad8
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
const Settings = require('@overleaf/settings')
|
||||
const { expect } = require('chai')
|
||||
const { db, ObjectId } = require('../../../app/js/mongodb')
|
||||
const async = require('async')
|
||||
const DocstoreApp = require('./helpers/DocstoreApp')
|
||||
const DocstoreClient = require('./helpers/DocstoreClient')
|
||||
const { Storage } = require('@google-cloud/storage')
|
||||
const Persistor = require('../../../app/js/PersistorManager')
|
||||
const { ReadableString } = require('@overleaf/stream-utils')
|
||||
const { callbackify } = require('node:util')
|
||||
import Settings from '@overleaf/settings'
|
||||
import { expect } from 'chai'
|
||||
import mongodb from '../../../app/js/mongodb.js'
|
||||
import async from 'async'
|
||||
import DocstoreApp from './helpers/DocstoreApp.js'
|
||||
import DocstoreClient from './helpers/DocstoreClient.js'
|
||||
import { Storage } from '@google-cloud/storage'
|
||||
import Persistor from '../../../app/js/PersistorManager.js'
|
||||
import { ReadableString } from '@overleaf/stream-utils'
|
||||
import { callbackify } from 'node:util'
|
||||
import Crypto from 'node:crypto'
|
||||
|
||||
const { db, ObjectId } = mongodb
|
||||
|
||||
async function uploadContent(path, json) {
|
||||
const stream = new ReadableString(JSON.stringify(json))
|
||||
@@ -275,9 +278,7 @@ describe('Archiving', function () {
|
||||
this.project_id = new ObjectId()
|
||||
this.timeout(1000 * 30)
|
||||
const quarterMegInBytes = 250000
|
||||
const bigLine = require('node:crypto')
|
||||
.randomBytes(quarterMegInBytes)
|
||||
.toString('hex')
|
||||
const bigLine = Crypto.randomBytes(quarterMegInBytes).toString('hex')
|
||||
this.doc = {
|
||||
_id: new ObjectId(),
|
||||
lines: [bigLine, bigLine, bigLine, bigLine],
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const { db, ObjectId } = require('../../../app/js/mongodb')
|
||||
const { expect } = require('chai')
|
||||
const DocstoreApp = require('./helpers/DocstoreApp')
|
||||
const Errors = require('../../../app/js/Errors')
|
||||
const Settings = require('@overleaf/settings')
|
||||
const { Storage } = require('@google-cloud/storage')
|
||||
const { promisify } = require('node:util')
|
||||
import mongodb from '../../../app/js/mongodb.js'
|
||||
import { expect } from 'chai'
|
||||
import DocstoreApp from './helpers/DocstoreApp.js'
|
||||
import Errors from '../../../app/js/Errors.js'
|
||||
import Settings from '@overleaf/settings'
|
||||
import { Storage } from '@google-cloud/storage'
|
||||
import { setTimeout as sleep } from 'node:timers/promises'
|
||||
|
||||
const sleep = promisify(setTimeout)
|
||||
import DocstoreClient from './helpers/DocstoreClient.js'
|
||||
|
||||
const DocstoreClient = require('./helpers/DocstoreClient')
|
||||
const { db, ObjectId } = mongodb
|
||||
|
||||
function deleteTestSuite(deleteDoc) {
|
||||
before(async function () {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
const { ObjectId } = require('mongodb-legacy')
|
||||
const async = require('async')
|
||||
const DocstoreApp = require('./helpers/DocstoreApp')
|
||||
const { callbackify } = require('node:util')
|
||||
import mongodb from 'mongodb-legacy'
|
||||
import async from 'async'
|
||||
import DocstoreApp from './helpers/DocstoreApp.js'
|
||||
import { callbackify } from 'node:util'
|
||||
import DocstoreClient from './helpers/DocstoreClient.js'
|
||||
|
||||
const DocstoreClient = require('./helpers/DocstoreClient')
|
||||
const { ObjectId } = mongodb
|
||||
|
||||
describe('Getting all docs', function () {
|
||||
beforeEach(function (done) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
const Settings = require('@overleaf/settings')
|
||||
const { ObjectId } = require('../../../app/js/mongodb')
|
||||
const DocstoreApp = require('./helpers/DocstoreApp')
|
||||
const DocstoreClient = require('./helpers/DocstoreClient')
|
||||
const { Storage } = require('@google-cloud/storage')
|
||||
import Settings from '@overleaf/settings'
|
||||
import mongodb from '../../../app/js/mongodb.js'
|
||||
import DocstoreApp from './helpers/DocstoreApp.js'
|
||||
import DocstoreClient from './helpers/DocstoreClient.js'
|
||||
import { Storage } from '@google-cloud/storage'
|
||||
|
||||
const { ObjectId } = mongodb
|
||||
|
||||
describe('Getting A Doc from Archive', function () {
|
||||
before(async function () {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const { ObjectId } = require('mongodb-legacy')
|
||||
const { expect } = require('chai')
|
||||
const DocstoreApp = require('./helpers/DocstoreApp')
|
||||
import mongodb from 'mongodb-legacy'
|
||||
import { expect } from 'chai'
|
||||
import DocstoreApp from './helpers/DocstoreApp.js'
|
||||
import DocstoreClient from './helpers/DocstoreClient.js'
|
||||
|
||||
const DocstoreClient = require('./helpers/DocstoreClient')
|
||||
const { ObjectId } = mongodb
|
||||
|
||||
describe('Getting a doc', function () {
|
||||
beforeEach(async function () {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
const { db } = require('../../../app/js/mongodb')
|
||||
const DocstoreApp = require('./helpers/DocstoreApp')
|
||||
const DocstoreClient = require('./helpers/DocstoreClient')
|
||||
const { expect } = require('chai')
|
||||
import mongodb from '../../../app/js/mongodb.js'
|
||||
import DocstoreApp from './helpers/DocstoreApp.js'
|
||||
import DocstoreClient from './helpers/DocstoreClient.js'
|
||||
import { expect } from 'chai'
|
||||
|
||||
const { db } = mongodb
|
||||
|
||||
describe('HealthChecker', function () {
|
||||
beforeEach('start', async function () {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const { ObjectId } = require('mongodb-legacy')
|
||||
const DocstoreApp = require('./helpers/DocstoreApp')
|
||||
import mongodb from 'mongodb-legacy'
|
||||
import DocstoreApp from './helpers/DocstoreApp.js'
|
||||
import DocstoreClient from './helpers/DocstoreClient.js'
|
||||
|
||||
const DocstoreClient = require('./helpers/DocstoreClient')
|
||||
const { ObjectId } = mongodb
|
||||
|
||||
describe('Applying updates to a doc', function () {
|
||||
beforeEach(async function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const app = require('../../../../app')
|
||||
const Settings = require('@overleaf/settings')
|
||||
require('./MongoHelper')
|
||||
import app from '../../../../app.js'
|
||||
import Settings from '@overleaf/settings'
|
||||
import './MongoHelper.js'
|
||||
|
||||
function startApp() {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -27,6 +27,6 @@ async function ensureRunning() {
|
||||
await appStartedPromise
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
ensureRunning,
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
let DocstoreClient
|
||||
const {
|
||||
import {
|
||||
fetchNothing,
|
||||
fetchJson,
|
||||
fetchJsonWithResponse,
|
||||
} = require('@overleaf/fetch-utils')
|
||||
const settings = require('@overleaf/settings')
|
||||
const Persistor = require('../../../../app/js/PersistorManager')
|
||||
} from '@overleaf/fetch-utils'
|
||||
import settings from '@overleaf/settings'
|
||||
import Persistor from '../../../../app/js/PersistorManager.js'
|
||||
|
||||
let DocstoreClient
|
||||
|
||||
async function streamToString(stream) {
|
||||
const chunks = []
|
||||
@@ -22,7 +23,7 @@ async function getStringFromPersistor(persistor, bucket, key) {
|
||||
return await streamToString(stream)
|
||||
}
|
||||
|
||||
module.exports = DocstoreClient = {
|
||||
export default DocstoreClient = {
|
||||
async createDoc(projectId, docId, lines, version, ranges) {
|
||||
return await DocstoreClient.updateDoc(
|
||||
projectId,
|
||||
|
||||
Reference in New Issue
Block a user