Merge pull request #16948 from overleaf/jpa-rails-sharelatex-rebranding-step-2

[web] migrate v1 api calls away from ShareLaTeX branded endpoints

GitOrigin-RevId: af08ee029d0cee8f0f171d21b4f2b0b76222b3f8
This commit is contained in:
Jakob Ackermann 2024-02-12 10:36:44 +00:00 committed by Copybot
parent 094e768766
commit 8523c21158
11 changed files with 36 additions and 39 deletions

View file

@ -170,7 +170,7 @@ module.exports = ExportsHandler = {
}
return request.post(
{
url: `${settings.apis.v1.url}/api/v1/sharelatex/exports`,
url: `${settings.apis.v1.url}/api/v1/overleaf/exports`,
auth: { user: settings.apis.v1.user, pass: settings.apis.v1.pass },
json: exportData,
timeout: settings.apis.v1.timeout,
@ -230,7 +230,7 @@ module.exports = ExportsHandler = {
}
return request.get(
{
url: `${settings.apis.v1.url}/api/v1/sharelatex/exports/${exportId}`,
url: `${settings.apis.v1.url}/api/v1/overleaf/exports/${exportId}`,
auth: { user: settings.apis.v1.user, pass: settings.apis.v1.pass },
timeout: settings.apis.v1.timeout,
},
@ -259,7 +259,7 @@ module.exports = ExportsHandler = {
}
return request.get(
{
url: `${settings.apis.v1.url}/api/v1/sharelatex/exports/${exportId}/${type}_url`,
url: `${settings.apis.v1.url}/api/v1/overleaf/exports/${exportId}/${type}_url`,
auth: { user: settings.apis.v1.user, pass: settings.apis.v1.pass },
timeout: settings.apis.v1.timeout,
},

View file

@ -12,7 +12,7 @@ module.exports = V1SubscriptionManager = {
{
method: 'GET',
url(v1Id) {
return `/api/v1/sharelatex/users/${v1Id}/subscriptions`
return `/api/v1/overleaf/users/${v1Id}/subscriptions`
},
},
callback
@ -25,7 +25,7 @@ module.exports = V1SubscriptionManager = {
{
method: 'DELETE',
url(v1Id) {
return `/api/v1/sharelatex/users/${v1Id}/subscription`
return `/api/v1/overleaf/users/${v1Id}/subscription`
},
},
callback

View file

@ -28,7 +28,7 @@ const TemplatesManager = {
_callback
) {
const callback = _.once(_callback)
const zipUrl = `${settings.apis.v1.url}/api/v1/sharelatex/templates/${templateVersionId}`
const zipUrl = `${settings.apis.v1.url}/api/v1/overleaf/templates/${templateVersionId}`
const zipReq = request(zipUrl, {
auth: {
user: settings.apis.v1.user,

View file

@ -254,7 +254,7 @@ const TokenAccessHandler = {
return callback(null, { allow: true })
}
V1Api.request(
{ url: `/api/v1/sharelatex/docs/${token}/is_published` },
{ url: `/api/v1/overleaf/docs/${token}/is_published` },
function (err, response, body) {
if (err != null) {
return callback(err)
@ -271,7 +271,7 @@ const TokenAccessHandler = {
exported: false,
})
}
const v1Url = `/api/v1/sharelatex/docs/${token}/info`
const v1Url = `/api/v1/overleaf/docs/${token}/info`
V1Api.request({ url: v1Url }, function (err, response, body) {
if (err != null) {
return callback(err)

View file

@ -74,7 +74,7 @@ const TokenGenerator = {
return V1Api.request(
{
url: `/api/v1/sharelatex/docs/read_token/${token}/exists`,
url: `/api/v1/overleaf/docs/read_token/${token}/exists`,
json: true,
},
function (err, response, body) {

View file

@ -21,7 +21,7 @@ module.exports = V1Handler = {
return V1Api.request(
{
method: 'POST',
url: '/api/v1/sharelatex/login',
url: '/api/v1/overleaf/login',
json: { email, password },
expectedStatusCodes: [403],
},
@ -58,7 +58,7 @@ module.exports = V1Handler = {
return V1Api.request(
{
method: 'POST',
url: '/api/v1/sharelatex/reset_password',
url: '/api/v1/overleaf/reset_password',
json: {
user_id: v1UserId,
password,

View file

@ -44,7 +44,7 @@ async function checkCert(ukamfDB, providerId) {
const { body } = await V1Api.request({
json: true,
qs: { university_id: providerId },
uri: '/api/v1/sharelatex/university_saml',
uri: '/api/v1/overleaf/university_saml',
})
// show notice if sso not currently enabled
if (body.sso_enabled === true) {

View file

@ -156,20 +156,17 @@ class MockV1Api extends AbstractMockApi {
}
applyRoutes() {
this.app.get(
'/api/v1/sharelatex/users/:v1_user_id/plan_code',
(req, res) => {
this.app.get('/api/v1/overleaf/users/:v1_user_id/plan_code', (req, res) => {
const user = this.users[req.params.v1_user_id]
if (user) {
res.json(user)
} else {
res.sendStatus(404)
}
}
)
})
this.app.get(
'/api/v1/sharelatex/users/:v1_user_id/subscriptions',
'/api/v1/overleaf/users/:v1_user_id/subscriptions',
(req, res) => {
const user = this.users[req.params.v1_user_id]
if (user && user.subscription) {
@ -181,7 +178,7 @@ class MockV1Api extends AbstractMockApi {
)
this.app.get(
'/api/v1/sharelatex/users/:v1_user_id/subscription_status',
'/api/v1/overleaf/users/:v1_user_id/subscription_status',
(req, res) => {
const user = this.users[req.params.v1_user_id]
if (user && user.subscription_status) {
@ -193,7 +190,7 @@ class MockV1Api extends AbstractMockApi {
)
this.app.delete(
'/api/v1/sharelatex/users/:v1_user_id/subscription',
'/api/v1/overleaf/users/:v1_user_id/subscription',
(req, res) => {
const user = this.users[req.params.v1_user_id]
if (user) {
@ -205,12 +202,12 @@ class MockV1Api extends AbstractMockApi {
}
)
this.app.post('/api/v1/sharelatex/users/:v1_user_id/sync', (req, res) => {
this.app.post('/api/v1/overleaf/users/:v1_user_id/sync', (req, res) => {
this.syncUserFeatures(req.params.v1_user_id)
res.sendStatus(200)
})
this.app.post('/api/v1/sharelatex/exports', (req, res) => {
this.app.post('/api/v1/overleaf/exports', (req, res) => {
this.exportParams = Object.assign({}, req.body)
res.json({ exportId: this.exportId })
})
@ -370,7 +367,7 @@ class MockV1Api extends AbstractMockApi {
}
})
this.app.put('/api/v1/sharelatex/users/:id/email', (req, res) => {
this.app.put('/api/v1/overleaf/users/:id/email', (req, res) => {
const { email } = req.body && req.body.user
if (this.existingEmails.includes(email)) {
res.sendStatus(409)
@ -380,7 +377,7 @@ class MockV1Api extends AbstractMockApi {
}
})
this.app.post('/api/v1/sharelatex/login', (req, res) => {
this.app.post('/api/v1/overleaf/login', (req, res) => {
for (const id in this.users) {
const user = this.users[id]
if (
@ -425,12 +422,12 @@ class MockV1Api extends AbstractMockApi {
}
})
this.app.get('/api/v1/sharelatex/docs/:token/is_published', (req, res) => {
this.app.get('/api/v1/overleaf/docs/:token/is_published', (req, res) => {
return res.json({ allow: true })
})
this.app.get(
'/api/v1/sharelatex/users/:user_id/docs/:token/info',
'/api/v1/overleaf/users/:user_id/docs/:token/info',
(req, res) => {
const info = this.getDocInfo(req.params.token) || {
exists: false,
@ -440,7 +437,7 @@ class MockV1Api extends AbstractMockApi {
}
)
this.app.get('/api/v1/sharelatex/docs/:token/info', (req, res) => {
this.app.get('/api/v1/overleaf/docs/:token/info', (req, res) => {
const info = this.getDocInfo(req.params.token) || {
exists: false,
exported: false,
@ -449,7 +446,7 @@ class MockV1Api extends AbstractMockApi {
})
this.app.get(
'/api/v1/sharelatex/docs/read_token/:token/exists',
'/api/v1/overleaf/docs/read_token/:token/exists',
(req, res) => {
res.json({ exists: false })
}

View file

@ -531,7 +531,7 @@ describe('ExportsHandler', function () {
it('should issue the request', function () {
return expect(this.stubPost.getCall(0).args[0]).to.deep.equal({
url: this.settings.apis.v1.url + '/api/v1/sharelatex/exports',
url: this.settings.apis.v1.url + '/api/v1/overleaf/exports',
auth: {
user: this.settings.apis.v1.user,
pass: this.settings.apis.v1.pass,
@ -626,7 +626,7 @@ describe('ExportsHandler', function () {
return expect(this.stubGet.getCall(0).args[0]).to.deep.equal({
url:
this.settings.apis.v1.url +
'/api/v1/sharelatex/exports/' +
'/api/v1/overleaf/exports/' +
this.export_id,
auth: {
user: this.settings.apis.v1.user,
@ -680,7 +680,7 @@ describe('ExportsHandler', function () {
return expect(this.stubGet.getCall(0).args[0]).to.deep.equal({
url:
this.settings.apis.v1.url +
'/api/v1/sharelatex/exports/' +
'/api/v1/overleaf/exports/' +
this.export_id +
'/zip_url',
auth: {

View file

@ -121,7 +121,7 @@ describe('TemplatesManager', function () {
it('should fetch zip from v1 based on template id', function () {
return this.request.should.have.been.calledWith(
`${this.v1Url}/api/v1/sharelatex/templates/${this.templateVersionId}`
`${this.v1Url}/api/v1/overleaf/templates/${this.templateVersionId}`
)
})

View file

@ -549,7 +549,7 @@ describe('TokenAccessHandler', function () {
it('should return response body', function () {
expect(
this.V1Api.request.calledWith({
url: `/api/v1/sharelatex/docs/${this.token}/is_published`,
url: `/api/v1/overleaf/docs/${this.token}/is_published`,
})
).to.equal(true)
expect(this.callback.calledWith(null, 'mock-data')).to.equal(true)
@ -617,7 +617,7 @@ describe('TokenAccessHandler', function () {
it('should return response body', function () {
expect(
this.V1Api.request.calledWith({
url: `/api/v1/sharelatex/docs/${this.token}/info`,
url: `/api/v1/overleaf/docs/${this.token}/info`,
})
).to.equal(true)
expect(this.callback.calledWith(null, 'mock-data')).to.equal(true)