Files
overleaf-cep/services/history-v1/api/swagger/project_import.js
T
Eric Mc Sween 3aa579f232 Merge pull request #24736 from overleaf/em-history-get-changes
Endpoint for getting history changes

GitOrigin-RevId: b96afed0492522d62df9c24390f76e5490afbb44
2025-04-11 08:05:48 +00:00

148 lines
3.0 KiB
JavaScript

'use strict'
const importSnapshot = {
'x-swagger-router-controller': 'project_import',
operationId: 'importSnapshot',
tags: ['ProjectImport'],
description: 'Import a snapshot from the current rails app.',
consumes: ['application/json'],
parameters: [
{
name: 'project_id',
in: 'path',
description: 'project id',
required: true,
type: 'string',
},
{
name: 'snapshot',
in: 'body',
description: 'Snapshot to import.',
required: true,
schema: {
$ref: '#/definitions/Snapshot',
},
},
],
responses: {
200: {
description: 'Imported',
},
409: {
description: 'Conflict: project already initialized',
},
404: {
description: 'No such project exists',
},
},
security: [
{
basic: [],
},
],
}
const importChanges = {
'x-swagger-router-controller': 'project_import',
operationId: 'importChanges',
tags: ['ProjectImport'],
description: 'Import changes for a project from the current rails app.',
consumes: ['application/json'],
parameters: [
{
name: 'project_id',
in: 'path',
description: 'project id',
required: true,
type: 'string',
},
{
name: 'end_version',
description: 'end_version of latest persisted chunk',
in: 'query',
required: true,
type: 'number',
},
{
name: 'return_snapshot',
description:
'optionally, return a snapshot with the latest hashed content',
in: 'query',
required: false,
type: 'string',
enum: ['hashed', 'none'],
},
{
name: 'changes',
in: 'body',
description: 'changes to be imported',
required: true,
schema: {
type: 'array',
items: {
$ref: '#/definitions/Change',
},
},
},
],
responses: {
201: {
description: 'Created',
schema: {
$ref: '#/definitions/Snapshot',
},
},
},
security: [
{
basic: [],
},
],
}
const getChanges = {
'x-swagger-router-controller': 'projects',
operationId: 'getChanges',
tags: ['Project'],
description: 'Get changes applied to a project',
parameters: [
{
name: 'project_id',
in: 'path',
description: 'project id',
required: true,
type: 'string',
},
{
name: 'since',
in: 'query',
description: 'start version',
required: false,
type: 'number',
},
],
responses: {
200: {
description: 'Success',
schema: {
type: 'array',
items: {
$ref: '#/definitions/Change',
},
},
},
},
security: [
{
basic: [],
},
],
}
exports.paths = {
'/projects/{project_id}/import': { post: importSnapshot },
'/projects/{project_id}/legacy_import': { post: importSnapshot },
'/projects/{project_id}/changes': { get: getChanges, post: importChanges },
'/projects/{project_id}/legacy_changes': { post: importChanges },
}