mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
ETAPI method to create note revision, #3509
This commit is contained in:
parent
4bdb94fbaa
commit
bb8496cb3f
@ -291,6 +291,33 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
|
/notes/{noteId}/note-revision:
|
||||||
|
parameters:
|
||||||
|
- name: noteId
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/EntityId'
|
||||||
|
- name: format
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
enum:
|
||||||
|
- html
|
||||||
|
- markdown
|
||||||
|
default: html
|
||||||
|
post:
|
||||||
|
description: Create a note revision for the given note
|
||||||
|
operationId: createNoteRevision
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: revision has been created
|
||||||
|
default:
|
||||||
|
description: unexpected error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Error'
|
||||||
/branches/{branchId}:
|
/branches/{branchId}:
|
||||||
parameters:
|
parameters:
|
||||||
- name: branchId
|
- name: branchId
|
||||||
|
@ -8,6 +8,7 @@ const v = require("./validators");
|
|||||||
const searchService = require("../services/search/services/search");
|
const searchService = require("../services/search/services/search");
|
||||||
const SearchContext = require("../services/search/search_context");
|
const SearchContext = require("../services/search/search_context");
|
||||||
const zipExportService = require("../services/export/zip");
|
const zipExportService = require("../services/export/zip");
|
||||||
|
const noteRevisionService = require("../services/note_revisions.js");
|
||||||
|
|
||||||
function register(router) {
|
function register(router) {
|
||||||
eu.route(router, 'get', '/etapi/notes', (req, res, next) => {
|
eu.route(router, 'get', '/etapi/notes', (req, res, next) => {
|
||||||
@ -143,6 +144,14 @@ function register(router) {
|
|||||||
|
|
||||||
zipExportService.exportToZip(taskContext, branch, format, res);
|
zipExportService.exportToZip(taskContext, branch, format, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eu.route(router, 'post' ,'/etapi/notes/:noteId/note-revision', (req, res, next) => {
|
||||||
|
const note = eu.getAndCheckNote(req.params.noteId);
|
||||||
|
|
||||||
|
note.saveNoteRevision();
|
||||||
|
|
||||||
|
return res.sendStatus(204);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSearchParams(req) {
|
function parseSearchParams(req) {
|
||||||
|
23
test-etapi/post-note-revision.http
Normal file
23
test-etapi/post-note-revision.http
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
POST {{triliumHost}}/etapi/create-note
|
||||||
|
Authorization: {{authToken}}
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"parentNoteId": "root",
|
||||||
|
"title": "Hello",
|
||||||
|
"type": "code",
|
||||||
|
"mime": "text/plain",
|
||||||
|
"content": "Hi there!"
|
||||||
|
}
|
||||||
|
|
||||||
|
> {% client.global.set("createdNoteId", response.body.note.noteId); %}
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
POST {{triliumHost}}/etapi/notes/{{createdNoteId}}/note-revision
|
||||||
|
Authorization: {{authToken}}
|
||||||
|
Content-Type: text/plain
|
||||||
|
|
||||||
|
Changed content
|
||||||
|
|
||||||
|
> {% client.assert(response.status === 204); %}
|
Loading…
x
Reference in New Issue
Block a user