| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- /* eslint-disable
- camelcase,
- handle-callback-err,
- no-unused-vars,
- */
- // TODO: This file was created by bulk-decaffeinate.
- // Fix any style issues and re-enable lint.
- /*
- * decaffeinate suggestions:
- * DS102: Remove unnecessary code created because of implicit returns
- * DS207: Consider shorter variations of null checks
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
- */
- let DocstoreClient
- const request = require('request').defaults({ jar: false })
- const { db, ObjectId } = require('../../../../app/js/mongojs')
- const settings = require('settings-sharelatex')
- const DocArchiveManager = require('../../../../app/js/DocArchiveManager.js')
- module.exports = DocstoreClient = {
- createDoc(project_id, doc_id, lines, version, ranges, callback) {
- if (callback == null) {
- callback = function (error) {}
- }
- return DocstoreClient.updateDoc(
- project_id,
- doc_id,
- lines,
- version,
- ranges,
- callback
- )
- },
- getDoc(project_id, doc_id, qs, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- return request.get(
- {
- url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`,
- json: true,
- qs
- },
- callback
- )
- },
- getAllDocs(project_id, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- return request.get(
- {
- url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc`,
- json: true
- },
- callback
- )
- },
- getAllRanges(project_id, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- return request.get(
- {
- url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/ranges`,
- json: true
- },
- callback
- )
- },
- updateDoc(project_id, doc_id, lines, version, ranges, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- return request.post(
- {
- url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`,
- json: {
- lines,
- version,
- ranges
- }
- },
- callback
- )
- },
- deleteDoc(project_id, doc_id, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- return request.del(
- {
- url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`
- },
- callback
- )
- },
- archiveAllDoc(project_id, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- return request.post(
- {
- url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/archive`
- },
- callback
- )
- },
- destroyAllDoc(project_id, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- return request.post(
- {
- url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/destroy`
- },
- callback
- )
- },
- getS3Doc(project_id, doc_id, callback) {
- if (callback == null) {
- callback = function (error, res, body) {}
- }
- const options = DocArchiveManager.buildS3Options(project_id + '/' + doc_id)
- options.json = true
- return request.get(options, callback)
- }
- }
|