mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Port services/cloning
This commit is contained in:
parent
e4556afcc9
commit
6cedad07e5
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const attributeService = require('../../services/attributes');
|
||||
const cloneService = require('../../services/cloning.js');
|
||||
const cloneService = require('../../services/cloning');
|
||||
const noteService = require('../../services/notes');
|
||||
const dateNoteService = require('../../services/date_notes.js');
|
||||
const dateUtils = require('../../services/date_utils');
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const cloningService = require('../../services/cloning.js');
|
||||
const cloningService = require('../../services/cloning');
|
||||
|
||||
function cloneNoteToBranch(req) {
|
||||
const {noteId, parentBranchId} = req.params;
|
||||
|
@ -27,7 +27,7 @@ const notesApiRoute = require('./api/notes.js');
|
||||
const branchesApiRoute = require('./api/branches.js');
|
||||
const attachmentsApiRoute = require('./api/attachments.js');
|
||||
const autocompleteApiRoute = require('./api/autocomplete.js');
|
||||
const cloningApiRoute = require('./api/cloning.js');
|
||||
const cloningApiRoute = require('./api/cloning');
|
||||
const revisionsApiRoute = require('./api/revisions');
|
||||
const recentChangesApiRoute = require('./api/recent_changes.js');
|
||||
const optionsApiRoute = require('./api/options.js');
|
||||
|
@ -9,7 +9,7 @@ const config = require('./config');
|
||||
const axios = require('axios');
|
||||
const dayjs = require('dayjs');
|
||||
const xml2js = require('xml2js');
|
||||
const cloningService = require('./cloning.js');
|
||||
const cloningService = require('./cloning');
|
||||
const appInfo = require('./app_info');
|
||||
const searchService = require('./search/services/search');
|
||||
const SearchContext = require('./search/search_context');
|
||||
|
@ -1,7 +1,7 @@
|
||||
const log = require('./log');
|
||||
const revisionService = require('./revisions');
|
||||
const becca = require('../becca/becca');
|
||||
const cloningService = require('./cloning.js');
|
||||
const cloningService = require('./cloning');
|
||||
const branchService = require('./branches');
|
||||
const utils = require('./utils');
|
||||
const eraseService = require("./erase");
|
||||
|
@ -7,7 +7,7 @@ const BBranch = require('../becca/entities/bbranch');
|
||||
const becca = require('../becca/becca');
|
||||
const log = require('./log');
|
||||
|
||||
function cloneNoteToParentNote(noteId, parentNoteId, prefix = null) {
|
||||
function cloneNoteToParentNote(noteId: string, parentNoteId: string, prefix: string | null = null) {
|
||||
if (!(noteId in becca.notes) || !(parentNoteId in becca.notes)) {
|
||||
return { success: false, message: 'Note cannot be cloned because either the cloned note or the intended parent is deleted.' };
|
||||
}
|
||||
@ -43,7 +43,7 @@ function cloneNoteToParentNote(noteId, parentNoteId, prefix = null) {
|
||||
};
|
||||
}
|
||||
|
||||
function cloneNoteToBranch(noteId, parentBranchId, prefix) {
|
||||
function cloneNoteToBranch(noteId: string, parentBranchId: string, prefix: string) {
|
||||
const parentBranch = becca.getBranch(parentBranchId);
|
||||
|
||||
if (!parentBranch) {
|
||||
@ -58,7 +58,7 @@ function cloneNoteToBranch(noteId, parentBranchId, prefix) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {
|
||||
function ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix: string) {
|
||||
if (!(noteId in becca.notes)) {
|
||||
return { branch: null, success: false, message: `Note '${noteId}' is deleted.` };
|
||||
} else if (!(parentNoteId in becca.notes)) {
|
||||
@ -89,7 +89,7 @@ function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {
|
||||
return { branch: branch, success: true };
|
||||
}
|
||||
|
||||
function ensureNoteIsAbsentFromParent(noteId, parentNoteId) {
|
||||
function ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string) {
|
||||
const branchId = sql.getValue(`SELECT branchId FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0`, [noteId, parentNoteId]);
|
||||
const branch = becca.getBranch(branchId);
|
||||
|
||||
@ -109,7 +109,7 @@ function ensureNoteIsAbsentFromParent(noteId, parentNoteId) {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleNoteInParent(present, noteId, parentNoteId, prefix) {
|
||||
function toggleNoteInParent(present: boolean, noteId: string, parentNoteId: string, prefix: string) {
|
||||
if (present) {
|
||||
return ensureNoteIsPresentInParent(noteId, parentNoteId, prefix);
|
||||
}
|
||||
@ -118,7 +118,7 @@ function toggleNoteInParent(present, noteId, parentNoteId, prefix) {
|
||||
}
|
||||
}
|
||||
|
||||
function cloneNoteAfter(noteId, afterBranchId) {
|
||||
function cloneNoteAfter(noteId: string, afterBranchId: string) {
|
||||
if (['_hidden', 'root'].includes(noteId)) {
|
||||
return { success: false, message: `Cloning the note '${noteId}' is forbidden.` };
|
||||
}
|
||||
@ -175,7 +175,7 @@ function cloneNoteAfter(noteId, afterBranchId) {
|
||||
return { success: true, branchId: branch.branchId };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export = {
|
||||
cloneNoteToBranch,
|
||||
cloneNoteToParentNote,
|
||||
ensureNoteIsPresentInParent,
|
@ -8,7 +8,7 @@ const sqlInit = require('../services/sql_init');
|
||||
const noteService = require('../services/notes');
|
||||
const attributeService = require('../services/attributes');
|
||||
const cls = require('../services/cls');
|
||||
const cloningService = require('../services/cloning.js');
|
||||
const cloningService = require('../services/cloning');
|
||||
const loremIpsum = require('lorem-ipsum').loremIpsum;
|
||||
|
||||
const noteCount = parseInt(process.argv[2]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user