projects.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. 'use strict'
  2. const Blob = require('overleaf-editor-core').Blob
  3. exports.paths = {
  4. '/projects': {
  5. post: {
  6. 'x-swagger-router-controller': 'projects',
  7. operationId: 'initializeProject',
  8. tags: ['Project'],
  9. description: 'Initialize project.',
  10. parameters: [
  11. {
  12. name: 'body',
  13. in: 'body',
  14. schema: {
  15. type: 'object',
  16. properties: {
  17. projectId: { type: 'string' },
  18. },
  19. },
  20. },
  21. ],
  22. responses: {
  23. 200: {
  24. description: 'Initialized',
  25. schema: {
  26. $ref: '#/definitions/Project',
  27. },
  28. },
  29. },
  30. security: [
  31. {
  32. basic: [],
  33. },
  34. ],
  35. },
  36. },
  37. '/projects/{project_id}': {
  38. delete: {
  39. 'x-swagger-router-controller': 'projects',
  40. operationId: 'deleteProject',
  41. tags: ['Project'],
  42. description: "Delete a project's history",
  43. parameters: [
  44. {
  45. name: 'project_id',
  46. in: 'path',
  47. description: 'project id',
  48. required: true,
  49. type: 'string',
  50. },
  51. ],
  52. responses: {
  53. 204: {
  54. description: 'Success',
  55. },
  56. },
  57. security: [
  58. {
  59. basic: [],
  60. },
  61. ],
  62. },
  63. },
  64. '/projects/{project_id}/blobs/{hash}': {
  65. get: {
  66. 'x-swagger-router-controller': 'projects',
  67. operationId: 'getProjectBlob',
  68. tags: ['Project'],
  69. description: 'Fetch blob content by its project id and hash.',
  70. parameters: [
  71. {
  72. name: 'project_id',
  73. in: 'path',
  74. description: 'project id',
  75. required: true,
  76. type: 'string',
  77. },
  78. {
  79. name: 'hash',
  80. in: 'path',
  81. description: 'Hexadecimal SHA-1 hash',
  82. required: true,
  83. type: 'string',
  84. pattern: Blob.HEX_HASH_RX_STRING,
  85. },
  86. ],
  87. produces: ['application/octet-stream'],
  88. responses: {
  89. 200: {
  90. description: 'Success',
  91. schema: {
  92. type: 'file',
  93. },
  94. },
  95. 404: {
  96. description: 'Not Found',
  97. schema: {
  98. $ref: '#/definitions/Error',
  99. },
  100. },
  101. },
  102. security: [{ jwt: [] }, { token: [] }],
  103. },
  104. put: {
  105. 'x-swagger-router-controller': 'projects',
  106. operationId: 'createProjectBlob',
  107. tags: ['Project'],
  108. description:
  109. 'Create blob to be used in a file addition operation when importing a' +
  110. ' snapshot or changes',
  111. parameters: [
  112. {
  113. name: 'project_id',
  114. in: 'path',
  115. description: 'project id',
  116. required: true,
  117. type: 'string',
  118. },
  119. {
  120. name: 'hash',
  121. in: 'path',
  122. description: 'Hexadecimal SHA-1 hash',
  123. required: true,
  124. type: 'string',
  125. pattern: Blob.HEX_HASH_RX_STRING,
  126. },
  127. ],
  128. responses: {
  129. 201: {
  130. description: 'Created',
  131. },
  132. },
  133. },
  134. },
  135. '/projects/{project_id}/latest/content': {
  136. get: {
  137. 'x-swagger-router-controller': 'projects',
  138. operationId: 'getLatestContent',
  139. tags: ['Project'],
  140. description:
  141. 'Get full content of the latest version. Text file ' +
  142. 'content is included, but binary files are just linked by hash.',
  143. parameters: [
  144. {
  145. name: 'project_id',
  146. in: 'path',
  147. description: 'project id',
  148. required: true,
  149. type: 'string',
  150. },
  151. ],
  152. responses: {
  153. 200: {
  154. description: 'Success',
  155. schema: {
  156. $ref: '#/definitions/Snapshot',
  157. },
  158. },
  159. 404: {
  160. description: 'Not Found',
  161. schema: {
  162. $ref: '#/definitions/Error',
  163. },
  164. },
  165. },
  166. },
  167. },
  168. '/projects/{project_id}/latest/hashed_content': {
  169. get: {
  170. 'x-swagger-router-controller': 'projects',
  171. operationId: 'getLatestHashedContent',
  172. tags: ['Project'],
  173. description:
  174. 'Get a snapshot of a project at the latest version ' +
  175. 'with the hashes for the contents each file',
  176. parameters: [
  177. {
  178. name: 'project_id',
  179. in: 'path',
  180. description: 'project id',
  181. required: true,
  182. type: 'string',
  183. },
  184. ],
  185. responses: {
  186. 200: {
  187. description: 'Success',
  188. schema: {
  189. $ref: '#/definitions/Snapshot',
  190. },
  191. },
  192. 404: {
  193. description: 'Not Found',
  194. schema: {
  195. $ref: '#/definitions/Error',
  196. },
  197. },
  198. },
  199. security: [
  200. {
  201. basic: [],
  202. },
  203. ],
  204. },
  205. },
  206. '/projects/{project_id}/latest/history': {
  207. get: {
  208. 'x-swagger-router-controller': 'projects',
  209. operationId: 'getLatestHistory',
  210. tags: ['Project'],
  211. description:
  212. 'Get the latest sequence of changes.' +
  213. ' TODO probably want a configurable depth.',
  214. parameters: [
  215. {
  216. name: 'project_id',
  217. in: 'path',
  218. description: 'project id',
  219. required: true,
  220. type: 'string',
  221. },
  222. ],
  223. responses: {
  224. 200: {
  225. description: 'Success',
  226. schema: {
  227. $ref: '#/definitions/ChunkResponse',
  228. },
  229. },
  230. 404: {
  231. description: 'Not Found',
  232. schema: {
  233. $ref: '#/definitions/Error',
  234. },
  235. },
  236. },
  237. },
  238. },
  239. '/projects/{project_id}/latest/persistedHistory': {
  240. get: {
  241. 'x-swagger-router-controller': 'projects',
  242. operationId: 'getLatestPersistedHistory',
  243. tags: ['Project'],
  244. description: 'Get the latest sequence of changes.',
  245. parameters: [
  246. {
  247. name: 'project_id',
  248. in: 'path',
  249. description: 'project id',
  250. required: true,
  251. type: 'string',
  252. },
  253. ],
  254. responses: {
  255. 200: {
  256. description: 'Success',
  257. schema: {
  258. $ref: '#/definitions/ChunkResponse',
  259. },
  260. },
  261. 404: {
  262. description: 'Not Found',
  263. schema: {
  264. $ref: '#/definitions/Error',
  265. },
  266. },
  267. },
  268. },
  269. },
  270. '/projects/{project_id}/versions/{version}/history': {
  271. get: {
  272. 'x-swagger-router-controller': 'projects',
  273. operationId: 'getHistory',
  274. tags: ['Project'],
  275. description:
  276. 'Get the sequence of changes that includes the given version.',
  277. parameters: [
  278. {
  279. name: 'project_id',
  280. in: 'path',
  281. description: 'project id',
  282. required: true,
  283. type: 'string',
  284. },
  285. {
  286. name: 'version',
  287. in: 'path',
  288. description: 'numeric version',
  289. required: true,
  290. type: 'number',
  291. },
  292. ],
  293. responses: {
  294. 200: {
  295. description: 'Success',
  296. schema: {
  297. $ref: '#/definitions/ChunkResponse',
  298. },
  299. },
  300. 404: {
  301. description: 'Not Found',
  302. schema: {
  303. $ref: '#/definitions/Error',
  304. },
  305. },
  306. },
  307. },
  308. },
  309. '/projects/{project_id}/timestamp/{timestamp}/history': {
  310. get: {
  311. 'x-swagger-router-controller': 'projects',
  312. operationId: 'getHistoryBefore',
  313. tags: ['Project'],
  314. description:
  315. 'Get the sequence of changes. ' + ' before the given timestamp',
  316. parameters: [
  317. {
  318. name: 'project_id',
  319. in: 'path',
  320. description: 'project id',
  321. required: true,
  322. type: 'string',
  323. },
  324. {
  325. name: 'timestamp',
  326. in: 'path',
  327. description: 'timestamp',
  328. required: true,
  329. type: 'string',
  330. format: 'date-time',
  331. },
  332. ],
  333. responses: {
  334. 200: {
  335. description: 'Success',
  336. schema: {
  337. $ref: '#/definitions/ChunkResponse',
  338. },
  339. },
  340. 404: {
  341. description: 'Not Found',
  342. schema: {
  343. $ref: '#/definitions/Error',
  344. },
  345. },
  346. },
  347. },
  348. },
  349. '/projects/{project_id}/version/{version}/zip': {
  350. get: {
  351. 'x-swagger-router-controller': 'projects',
  352. operationId: 'getZip',
  353. tags: ['Project'],
  354. description: 'Download zip with project content',
  355. parameters: [
  356. {
  357. name: 'project_id',
  358. in: 'path',
  359. description: 'project id',
  360. required: true,
  361. type: 'string',
  362. },
  363. {
  364. name: 'version',
  365. in: 'path',
  366. description: 'numeric version',
  367. required: true,
  368. type: 'number',
  369. },
  370. ],
  371. produces: ['application/octet-stream'],
  372. responses: {
  373. 200: {
  374. description: 'success',
  375. },
  376. 404: {
  377. description: 'not found',
  378. },
  379. },
  380. security: [
  381. {
  382. token: [],
  383. },
  384. ],
  385. },
  386. post: {
  387. 'x-swagger-router-controller': 'projects',
  388. operationId: 'createZip',
  389. tags: ['Project'],
  390. description:
  391. 'Create a zip file with project content. Returns a link to be polled.',
  392. parameters: [
  393. {
  394. name: 'project_id',
  395. in: 'path',
  396. description: 'project id',
  397. required: true,
  398. type: 'string',
  399. },
  400. {
  401. name: 'version',
  402. in: 'path',
  403. description: 'numeric version',
  404. required: true,
  405. type: 'number',
  406. },
  407. ],
  408. responses: {
  409. 200: {
  410. description: 'success',
  411. schema: {
  412. $ref: '#/definitions/ZipInfo',
  413. },
  414. },
  415. 404: {
  416. description: 'not found',
  417. },
  418. },
  419. security: [
  420. {
  421. basic: [],
  422. },
  423. ],
  424. },
  425. },
  426. }