mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	Merge pull request #259 from TriliumNext/feature/server_esm
Server ESM port: Basic imports
This commit is contained in:
		
						commit
						1a5649e8ac
					
				
							
								
								
									
										17
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | |||||||
|  | { | ||||||
|  |     "version": "2.0.0", | ||||||
|  |     "tasks": [ | ||||||
|  |       { | ||||||
|  |         "type": "npm", | ||||||
|  |         "script": "errors", | ||||||
|  |         "problemMatcher": "$tsc-watch", | ||||||
|  |         "isBackground": true, | ||||||
|  |         "presentation": { | ||||||
|  |           "revealProblems": "never" | ||||||
|  |         }, | ||||||
|  |         "runOptions": { | ||||||
|  |           "runOn": "folderOpen" | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     ] | ||||||
|  |   } | ||||||
							
								
								
									
										18
									
								
								electron.ts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								electron.ts
									
									
									
									
									
								
							| @ -1,10 +1,12 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import electron = require("electron"); | import electron from "electron"; | ||||||
| import sqlInit = require("./src/services/sql_init"); | import electronDebug from "electron-debug"; | ||||||
| import appIconService = require("./src/services/app_icon"); | import electronDl from "electron-dl"; | ||||||
| import windowService = require("./src/services/window"); | import sqlInit from "./src/services/sql_init.js"; | ||||||
| import tray = require("./src/services/tray"); | import appIconService from "./src/services/app_icon.js"; | ||||||
|  | import windowService from "./src/services/window.js"; | ||||||
|  | import tray from "./src/services/tray.js"; | ||||||
| 
 | 
 | ||||||
| // Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
 | // Prevent Trilium starting twice on first install and on uninstall for the Windows installer.
 | ||||||
| if (require('electron-squirrel-startup')) { | if (require('electron-squirrel-startup')) { | ||||||
| @ -12,11 +14,11 @@ if (require('electron-squirrel-startup')) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Adds debug features like hotkeys for triggering dev tools and reload
 | // Adds debug features like hotkeys for triggering dev tools and reload
 | ||||||
| require("electron-debug")(); | electronDebug(); | ||||||
| 
 | 
 | ||||||
| appIconService.installLocalAppIcon(); | appIconService.installLocalAppIcon(); | ||||||
| 
 | 
 | ||||||
| require("electron-dl")({ saveAs: true }); | electronDl({ saveAs: true }); | ||||||
| 
 | 
 | ||||||
| // needed for excalidraw export https://github.com/zadam/trilium/issues/4271
 | // needed for excalidraw export https://github.com/zadam/trilium/issues/4271
 | ||||||
| electron.app.commandLine.appendSwitch( | electron.app.commandLine.appendSwitch( | ||||||
| @ -65,4 +67,4 @@ electron.app.on("will-quit", () => { | |||||||
| // this is to disable electron warning spam in the dev console (local development only)
 | // this is to disable electron warning spam in the dev console (local development only)
 | ||||||
| process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; | process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; | ||||||
| 
 | 
 | ||||||
| require("./src/www.js"); | require('./src/www.js'); | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										11
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -113,6 +113,7 @@ | |||||||
|         "@types/sax": "^1.2.7", |         "@types/sax": "^1.2.7", | ||||||
|         "@types/semver": "^7.5.8", |         "@types/semver": "^7.5.8", | ||||||
|         "@types/serve-favicon": "^2.5.7", |         "@types/serve-favicon": "^2.5.7", | ||||||
|  |         "@types/session-file-store": "^1.2.5", | ||||||
|         "@types/stream-throttle": "^0.1.4", |         "@types/stream-throttle": "^0.1.4", | ||||||
|         "@types/tmp": "^0.2.6", |         "@types/tmp": "^0.2.6", | ||||||
|         "@types/turndown": "^5.0.4", |         "@types/turndown": "^5.0.4", | ||||||
| @ -2616,6 +2617,16 @@ | |||||||
|         "@types/node": "*" |         "@types/node": "*" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/@types/session-file-store": { | ||||||
|  |       "version": "1.2.5", | ||||||
|  |       "resolved": "https://registry.npmjs.org/@types/session-file-store/-/session-file-store-1.2.5.tgz", | ||||||
|  |       "integrity": "sha512-xjIyh40IznXLrvbAY/nmxu5cMcPcE3ZoDrSDvd02m6p8UjUgOtZAGI7Os5DDd6THuxClLWNhFo/awy1tYp64Bg==", | ||||||
|  |       "dev": true, | ||||||
|  |       "dependencies": { | ||||||
|  |         "@types/express": "*", | ||||||
|  |         "@types/express-session": "*" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/@types/stream-throttle": { |     "node_modules/@types/stream-throttle": { | ||||||
|       "version": "0.1.4", |       "version": "0.1.4", | ||||||
|       "resolved": "https://registry.npmjs.org/@types/stream-throttle/-/stream-throttle-0.1.4.tgz", |       "resolved": "https://registry.npmjs.org/@types/stream-throttle/-/stream-throttle-0.1.4.tgz", | ||||||
|  | |||||||
| @ -41,7 +41,8 @@ | |||||||
|     "make-electron": "npm run webpack && npm run prepare-dist && electron-forge make", |     "make-electron": "npm run webpack && npm run prepare-dist && electron-forge make", | ||||||
|     "package-electron": "electron-forge package", |     "package-electron": "electron-forge package", | ||||||
|     "prepare-dist": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts", |     "prepare-dist": "rimraf ./dist && tsc && ts-node ./bin/copy-dist.ts", | ||||||
|     "update-build-info": "ts-node bin/update-build-info.ts" |     "update-build-info": "ts-node bin/update-build-info.ts", | ||||||
|  |     "errors": "tsc --watch --noEmit" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@braintree/sanitize-url": "^7.1.0", |     "@braintree/sanitize-url": "^7.1.0", | ||||||
| @ -145,6 +146,7 @@ | |||||||
|     "@types/sax": "^1.2.7", |     "@types/sax": "^1.2.7", | ||||||
|     "@types/semver": "^7.5.8", |     "@types/semver": "^7.5.8", | ||||||
|     "@types/serve-favicon": "^2.5.7", |     "@types/serve-favicon": "^2.5.7", | ||||||
|  |     "@types/session-file-store": "^1.2.5", | ||||||
|     "@types/stream-throttle": "^0.1.4", |     "@types/stream-throttle": "^0.1.4", | ||||||
|     "@types/tmp": "^0.2.6", |     "@types/tmp": "^0.2.6", | ||||||
|     "@types/turndown": "^5.0.4", |     "@types/turndown": "^5.0.4", | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import etapi = require("../support/etapi"); | import etapi from "../support/etapi.js"; | ||||||
| 
 | 
 | ||||||
| etapi.describeEtapi("app_info", () => { | etapi.describeEtapi("app_info", () => { | ||||||
|   it("get", async () => { |   it("get", async () => { | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import etapi = require("../support/etapi"); | import etapi from "../support/etapi.js"; | ||||||
| 
 | 
 | ||||||
| etapi.describeEtapi("backup", () => { | etapi.describeEtapi("backup", () => { | ||||||
|   it("create", async () => { |   it("create", async () => { | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| import etapi = require("../support/etapi"); | import etapi from "../support/etapi.js"; | ||||||
| import fs = require("fs"); | import fs from "fs"; | ||||||
| import path = require("path"); | import path from "path"; | ||||||
| 
 | 
 | ||||||
| etapi.describeEtapi("import", () => { | etapi.describeEtapi("import", () => { | ||||||
|   // temporarily skip this test since test-export.zip is missing
 |   // temporarily skip this test since test-export.zip is missing
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import crypto = require("crypto"); | import crypto from "crypto"; | ||||||
| import etapi = require("../support/etapi"); | import etapi from "../support/etapi"; | ||||||
| 
 | 
 | ||||||
| etapi.describeEtapi("notes", () => { | etapi.describeEtapi("notes", () => { | ||||||
|   it("create", async () => { |   it("create", async () => { | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| import BNote = require("../../src/becca/entities/bnote"); | import BNote from "../../src/becca/entities/bnote.js"; | ||||||
| import BBranch = require("../../src/becca/entities/bbranch"); | import BBranch from "../../src/becca/entities/bbranch.js"; | ||||||
| import BAttribute = require("../../src/becca/entities/battribute"); | import BAttribute from "../../src/becca/entities/battribute.js"; | ||||||
| import becca = require("../../src/becca/becca"); | import becca from "../../src/becca/becca.js"; | ||||||
| import randtoken = require("rand-token"); | import randtoken from "rand-token"; | ||||||
| import SearchResult = require("../../src/services/search/search_result"); | import SearchResult from "../../src/services/search/search_result.js"; | ||||||
| import { NoteType } from "../../src/becca/entities/rows"; | import { NoteType } from "../../src/becca/entities/rows"; | ||||||
| randtoken.generator({ source: "crypto" }); | randtoken.generator({ source: "crypto" }); | ||||||
| 
 | 
 | ||||||
| @ -80,7 +80,7 @@ function note(title: string, extraParams = {}) { | |||||||
|   return new NoteBuilder(note); |   return new NoteBuilder(note); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|   NoteBuilder, |   NoteBuilder, | ||||||
|   findNoteByTitle, |   findNoteByTitle, | ||||||
|   note, |   note, | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import lex = require("../../src/services/search/services/lex"); | import lex from "../../src/services/search/services/lex.js"; | ||||||
| 
 | 
 | ||||||
| describe("Lexer fulltext", () => { | describe("Lexer fulltext", () => { | ||||||
|   it("simple lexing", () => { |   it("simple lexing", () => { | ||||||
|  | |||||||
| @ -1,24 +1,26 @@ | |||||||
| const handleParens = require('../../src/services/search/services/handle_parens'); | import handleParens from "../../src/services/search/services/handle_parens"; | ||||||
|  | import { TokenStructure } from "../../src/services/search/services/types"; | ||||||
| 
 | 
 | ||||||
| describe("Parens handler", () => { | describe("Parens handler", () => { | ||||||
|     it("handles parens", () => { |     it("handles parens", () => { | ||||||
|         const input = ["(", "hello", ")", "and", "(", "(", "pick", "one", ")", "and", "another", ")"] |         const input = ["(", "hello", ")", "and", "(", "(", "pick", "one", ")", "and", "another", ")"] | ||||||
|             .map(token => ({token})); |             .map(token => ({token})); | ||||||
| 
 | 
 | ||||||
|         expect(handleParens(input)) |         const actual: TokenStructure = [ | ||||||
|             .toEqual([ |             [ | ||||||
|  |                 {token: "hello"} | ||||||
|  |             ], | ||||||
|  |             {token: "and"}, | ||||||
|  |             [ | ||||||
|                 [ |                 [ | ||||||
|                     {token: "hello"} |                     {token: "pick"}, | ||||||
|  |                     {token: "one"} | ||||||
|                 ], |                 ], | ||||||
|                 {token: "and"}, |                 {token: "and"}, | ||||||
|                 [ |                 {token: "another"} | ||||||
|                     [ |             ] | ||||||
|                         {token: "pick"}, |         ]; | ||||||
|                         {token: "one"} | 
 | ||||||
|                     ], |         expect(handleParens(input)).toEqual(actual); | ||||||
|                     {token: "and"}, |  | ||||||
|                     {token: "another"} |  | ||||||
|                 ] |  | ||||||
|             ]); |  | ||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
|  | |||||||
| @ -2,9 +2,9 @@ | |||||||
| // There are many issues with the types of the parser e.g. "parse" function returns "Expression"
 | // There are many issues with the types of the parser e.g. "parse" function returns "Expression"
 | ||||||
| // but we access properties like "subExpressions" which is not defined in the "Expression" class.
 | // but we access properties like "subExpressions" which is not defined in the "Expression" class.
 | ||||||
| 
 | 
 | ||||||
| import Expression = require('../../src/services/search/expressions/expression'); | import Expression from "../../src/services/search/expressions/expression.js"; | ||||||
| import SearchContext = require('../../src/services/search/search_context'); | import SearchContext from "../../src/services/search/search_context.js"; | ||||||
| import parse = require('../../src/services/search/services/parse'); | import parse from "../../src/services/search/services/parse.js"; | ||||||
| 
 | 
 | ||||||
| function tokens(toks: Array<string>, cur = 0): Array<any> { | function tokens(toks: Array<string>, cur = 0): Array<any> { | ||||||
|     return toks.map((arg) => { |     return toks.map((arg) => { | ||||||
|  | |||||||
| @ -1,11 +1,10 @@ | |||||||
| import searchService = require('../../src/services/search/services/search'); | import searchService from "../../src/services/search/services/search.js"; | ||||||
| import BNote = require('../../src/becca/entities/bnote'); | import BNote from "../../src/becca/entities/bnote.js"; | ||||||
| import BBranch = require('../../src/becca/entities/bbranch'); | import BBranch from "../../src/becca/entities/bbranch.js"; | ||||||
| import SearchContext = require('../../src/services/search/search_context'); | import SearchContext from "../../src/services/search/search_context.js"; | ||||||
| import dateUtils = require('../../src/services/date_utils'); | import dateUtils from "../../src/services/date_utils.js"; | ||||||
| import becca = require('../../src/becca/becca'); | import becca from "../../src/becca/becca.js"; | ||||||
| // const { NoteBuilder, findNoteByTitle, note } = require("./becca_mocking");
 | import becca_mocking from "./becca_mocking.js"; | ||||||
| import becca_mocking = require('./becca_mocking'); |  | ||||||
| 
 | 
 | ||||||
| describe('Search', () => { | describe('Search', () => { | ||||||
|     let rootNote: any; |     let rootNote: any; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import becca_mocking = require('./becca_mocking'); | import becca_mocking from "./becca_mocking.js"; | ||||||
| import ValueExtractor = require('../../src/services/search/value_extractor'); | import ValueExtractor from "../../src/services/search/value_extractor.js"; | ||||||
| import becca = require('../../src/becca/becca'); | import becca from "../../src/becca/becca.js"; | ||||||
| import SearchContext = require('../../src/services/search/search_context'); | import SearchContext from "../../src/services/search/search_context.js"; | ||||||
| 
 | 
 | ||||||
| const dsc = new SearchContext(); | const dsc = new SearchContext(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import child_process = require("child_process"); | import child_process from "child_process"; | ||||||
| import kill = require("tree-kill"); | import kill from "tree-kill"; | ||||||
| 
 | 
 | ||||||
| let etapiAuthToken: string | undefined; | let etapiAuthToken: string | undefined; | ||||||
| 
 | 
 | ||||||
| @ -164,7 +164,7 @@ function checkStatus(response: Response): void { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export { | export default { | ||||||
|   describeEtapi, |   describeEtapi, | ||||||
|   getEtapi, |   getEtapi, | ||||||
|   getEtapiResponse, |   getEtapiResponse, | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import anonymizationService = require('./services/anonymization'); | import anonymizationService from "./services/anonymization.js"; | ||||||
| import sqlInit = require('./services/sql_init'); | import sqlInit from "./services/sql_init.js"; | ||||||
| require('./becca/entity_constructor'); | require('./becca/entity_constructor'); | ||||||
| 
 | 
 | ||||||
| sqlInit.dbReady.then(async () => { | sqlInit.dbReady.then(async () => { | ||||||
|  | |||||||
							
								
								
									
										20
									
								
								src/app.ts
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/app.ts
									
									
									
									
									
								
							| @ -1,11 +1,11 @@ | |||||||
| import express = require('express'); | import express from "express"; | ||||||
| import path = require('path'); | import path from "path"; | ||||||
| import favicon = require('serve-favicon'); | import favicon from "serve-favicon"; | ||||||
| import cookieParser = require('cookie-parser'); | import cookieParser from "cookie-parser"; | ||||||
| import helmet = require('helmet'); | import helmet from "helmet"; | ||||||
| import compression = require('compression'); | import compression from "compression"; | ||||||
| import sessionParser = require('./routes/session_parser'); | import sessionParser from "./routes/session_parser.js"; | ||||||
| import utils = require('./services/utils'); | import utils from "./services/utils.js"; | ||||||
| 
 | 
 | ||||||
| require('./services/handlers'); | require('./services/handlers'); | ||||||
| require('./becca/becca_loader'); | require('./becca/becca_loader'); | ||||||
| @ -20,7 +20,7 @@ if (!utils.isElectron()) { | |||||||
|     app.use(compression()); // HTTP compression
 |     app.use(compression()); // HTTP compression
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| app.use(helmet.default({ | app.use(helmet({ | ||||||
|     hidePoweredBy: false, // errors out in electron
 |     hidePoweredBy: false, // errors out in electron
 | ||||||
|     contentSecurityPolicy: false, |     contentSecurityPolicy: false, | ||||||
|     crossOriginEmbedderPolicy: false |     crossOriginEmbedderPolicy: false | ||||||
| @ -57,4 +57,4 @@ if (utils.isElectron()) { | |||||||
|     require('@electron/remote/main').initialize(); |     require('@electron/remote/main').initialize(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = app; | export default app; | ||||||
|  | |||||||
| @ -1,17 +1,17 @@ | |||||||
| import sql = require('../services/sql'); | import sql from "../services/sql.js"; | ||||||
| import NoteSet = require('../services/search/note_set'); | import NoteSet from "../services/search/note_set.js"; | ||||||
| import NotFoundError = require('../errors/not_found_error'); | import NotFoundError from "../errors/not_found_error.js"; | ||||||
| import BOption = require('./entities/boption'); | import BOption from "./entities/boption.js"; | ||||||
| import BNote = require('./entities/bnote'); | import BNote from "./entities/bnote.js"; | ||||||
| import BEtapiToken = require('./entities/betapi_token'); | import BEtapiToken from "./entities/betapi_token.js"; | ||||||
| import BAttribute = require('./entities/battribute'); | import BAttribute from "./entities/battribute.js"; | ||||||
| import BBranch = require('./entities/bbranch'); | import BBranch from "./entities/bbranch.js"; | ||||||
| import BRevision = require('./entities/brevision'); | import BRevision from "./entities/brevision.js"; | ||||||
| import BAttachment = require('./entities/battachment'); | import BAttachment from "./entities/battachment.js"; | ||||||
| import { AttachmentRow, RevisionRow } from './entities/rows'; | import { AttachmentRow, RevisionRow } from './entities/rows'; | ||||||
| import BBlob = require('./entities/bblob'); | import BBlob from "./entities/bblob.js"; | ||||||
| import BRecentNote = require('./entities/brecent_note'); | import BRecentNote from "./entities/brecent_note.js"; | ||||||
| import AbstractBeccaEntity = require('./entities/abstract_becca_entity'); | import AbstractBeccaEntity from "./entities/abstract_becca_entity.js"; | ||||||
| 
 | 
 | ||||||
| interface AttachmentOpts { | interface AttachmentOpts { | ||||||
|     includeContentLength?: boolean; |     includeContentLength?: boolean; | ||||||
| @ -155,9 +155,7 @@ export default class Becca { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     getRevision(revisionId: string): BRevision | null { |     getRevision(revisionId: string): BRevision | null { | ||||||
|         const row = sql.getRow("SELECT * FROM revisions WHERE revisionId = ?", [revisionId]); |         const row = sql.getRow<RevisionRow | null>("SELECT * FROM revisions WHERE revisionId = ?", [revisionId]); | ||||||
| 
 |  | ||||||
|         const BRevision = require('./entities/brevision'); // avoiding circular dependency problems
 |  | ||||||
|         return row ? new BRevision(row) : null; |         return row ? new BRevision(row) : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -179,9 +177,7 @@ export default class Becca { | |||||||
|                WHERE attachmentId = ? AND isDeleted = 0` |                WHERE attachmentId = ? AND isDeleted = 0` | ||||||
|             : `SELECT * FROM attachments WHERE attachmentId = ? AND isDeleted = 0`; |             : `SELECT * FROM attachments WHERE attachmentId = ? AND isDeleted = 0`; | ||||||
| 
 | 
 | ||||||
|         const BAttachment = require('./entities/battachment'); // avoiding circular dependency problems
 |         return sql.getRows<AttachmentRow>(query, [attachmentId]) | ||||||
| 
 |  | ||||||
|         return sql.getRows(query, [attachmentId]) |  | ||||||
|             .map(row => new BAttachment(row))[0]; |             .map(row => new BAttachment(row))[0]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -194,7 +190,6 @@ export default class Becca { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     getAttachments(attachmentIds: string[]): BAttachment[] { |     getAttachments(attachmentIds: string[]): BAttachment[] { | ||||||
|         const BAttachment = require('./entities/battachment'); // avoiding circular dependency problems
 |  | ||||||
|         return sql.getManyRows<AttachmentRow>("SELECT * FROM attachments WHERE attachmentId IN (???) AND isDeleted = 0", attachmentIds) |         return sql.getManyRows<AttachmentRow>("SELECT * FROM attachments WHERE attachmentId IN (???) AND isDeleted = 0", attachmentIds) | ||||||
|             .map(row => new BAttachment(row)); |             .map(row => new BAttachment(row)); | ||||||
|     } |     } | ||||||
| @ -204,9 +199,7 @@ export default class Becca { | |||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const row = sql.getRow("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]); |         const row = sql.getRow<BBlob | null>("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]); | ||||||
| 
 |  | ||||||
|         const BBlob = require('./entities/bblob'); // avoiding circular dependency problems
 |  | ||||||
|         return row ? new BBlob(row) : null; |         return row ? new BBlob(row) : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -248,16 +241,12 @@ export default class Becca { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     getRecentNotesFromQuery(query: string, params: string[] = []): BRecentNote[] { |     getRecentNotesFromQuery(query: string, params: string[] = []): BRecentNote[] { | ||||||
|         const rows = sql.getRows(query, params); |         const rows = sql.getRows<BRecentNote>(query, params); | ||||||
| 
 |  | ||||||
|         const BRecentNote = require('./entities/brecent_note'); // avoiding circular dependency problems
 |  | ||||||
|         return rows.map(row => new BRecentNote(row)); |         return rows.map(row => new BRecentNote(row)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     getRevisionsFromQuery(query: string, params: string[] = []): BRevision[] { |     getRevisionsFromQuery(query: string, params: string[] = []): BRevision[] { | ||||||
|         const rows = sql.getRows<RevisionRow>(query, params); |         const rows = sql.getRows<RevisionRow>(query, params); | ||||||
| 
 |  | ||||||
|         const BRevision = require('./entities/brevision'); // avoiding circular dependency problems
 |  | ||||||
|         return rows.map(row => new BRevision(row)); |         return rows.map(row => new BRevision(row)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -4,4 +4,4 @@ import Becca from "./becca-interface"; | |||||||
| 
 | 
 | ||||||
| const becca = new Becca(); | const becca = new Becca(); | ||||||
| 
 | 
 | ||||||
| export = becca; | export default becca; | ||||||
|  | |||||||
| @ -1,26 +1,28 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sql = require('../services/sql'); | import sql from "../services/sql.js"; | ||||||
| import eventService = require('../services/events'); | import eventService from "../services/events.js"; | ||||||
| import becca = require('./becca'); | import becca from "./becca.js"; | ||||||
| import sqlInit = require('../services/sql_init'); | import sqlInit from "../services/sql_init.js"; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| import BNote = require('./entities/bnote'); | import BNote from "./entities/bnote.js"; | ||||||
| import BBranch = require('./entities/bbranch'); | import BBranch from "./entities/bbranch.js"; | ||||||
| import BAttribute = require('./entities/battribute'); | import BAttribute from "./entities/battribute.js"; | ||||||
| import BOption = require('./entities/boption'); | import BOption from "./entities/boption.js"; | ||||||
| import BEtapiToken = require('./entities/betapi_token'); | import BEtapiToken from "./entities/betapi_token.js"; | ||||||
| import cls = require('../services/cls'); | import cls from "../services/cls.js"; | ||||||
| import entityConstructor = require('../becca/entity_constructor'); | import entityConstructor from "../becca/entity_constructor.js"; | ||||||
| import { AttributeRow, BranchRow, EtapiTokenRow, NoteRow, OptionRow } from './entities/rows'; | import { AttributeRow, BranchRow, EtapiTokenRow, NoteRow, OptionRow } from './entities/rows'; | ||||||
| import AbstractBeccaEntity = require('./entities/abstract_becca_entity'); | import AbstractBeccaEntity from "./entities/abstract_becca_entity.js"; | ||||||
|  | import options_init from "../services/options_init.js"; | ||||||
|  | import ws from "../services/ws.js"; | ||||||
| 
 | 
 | ||||||
| const beccaLoaded = new Promise<void>((res, rej) => { | const beccaLoaded = new Promise<void>((res, rej) => { | ||||||
|     sqlInit.dbReady.then(() => { |     sqlInit.dbReady.then(() => { | ||||||
|         cls.init(() => { |         cls.init(() => { | ||||||
|             load(); |             load(); | ||||||
| 
 | 
 | ||||||
|             require('../services/options_init').initStartupOptions(); |             options_init.initStartupOptions(); | ||||||
| 
 | 
 | ||||||
|             res(); |             res(); | ||||||
|         }); |         }); | ||||||
| @ -73,7 +75,7 @@ function load() { | |||||||
| function reload(reason: string) { | function reload(reason: string) { | ||||||
|     load(); |     load(); | ||||||
| 
 | 
 | ||||||
|     require('../services/ws').reloadFrontend(reason || "becca reloaded"); |     ws.reloadFrontend(reason || "becca reloaded"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| eventService.subscribeBeccaLoader([eventService.ENTITY_CHANGE_SYNCED], ({ entityName, entityRow }) => { | eventService.subscribeBeccaLoader([eventService.ENTITY_CHANGE_SYNCED], ({ entityName, entityRow }) => { | ||||||
| @ -286,7 +288,7 @@ eventService.subscribeBeccaLoader(eventService.ENTER_PROTECTED_SESSION, () => { | |||||||
| 
 | 
 | ||||||
| eventService.subscribeBeccaLoader(eventService.LEAVE_PROTECTED_SESSION, load); | eventService.subscribeBeccaLoader(eventService.LEAVE_PROTECTED_SESSION, load); | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     load, |     load, | ||||||
|     reload, |     reload, | ||||||
|     beccaLoaded |     beccaLoaded | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import becca = require('./becca'); | import becca from "./becca.js"; | ||||||
| import cls = require('../services/cls'); | import cls from "../services/cls.js"; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| 
 | 
 | ||||||
| function isNotePathArchived(notePath: string[]) { | function isNotePathArchived(notePath: string[]) { | ||||||
|     const noteId = notePath[notePath.length - 1]; |     const noteId = notePath[notePath.length - 1]; | ||||||
| @ -82,7 +82,7 @@ function getNoteTitleForPath(notePathArray: string[]) { | |||||||
|     return titles.join(' / '); |     return titles.join(' / '); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getNoteTitle, |     getNoteTitle, | ||||||
|     getNoteTitleForPath, |     getNoteTitleForPath, | ||||||
|     isNotePathArchived |     isNotePathArchived | ||||||
|  | |||||||
| @ -1,14 +1,14 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import entityChangesService = require('../../services/entity_changes'); | import entityChangesService from "../../services/entity_changes.js"; | ||||||
| import eventService = require('../../services/events'); | import eventService from "../../services/events.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import cls = require('../../services/cls'); | import cls from "../../services/cls.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService from "../../services/protected_session.js"; | ||||||
| import blobService = require('../../services/blob'); | import blobService from "../../services/blob.js"; | ||||||
| import Becca, { ConstructorData } from '../becca-interface'; | import Becca, { ConstructorData } from '../becca-interface'; | ||||||
| 
 | 
 | ||||||
| let becca: Becca; | let becca: Becca; | ||||||
| @ -327,4 +327,4 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = AbstractBeccaEntity; | export default AbstractBeccaEntity; | ||||||
|  | |||||||
| @ -1,14 +1,15 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService from "../../services/protected_session.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import { AttachmentRow } from './rows'; | import { AttachmentRow } from './rows'; | ||||||
| import BNote = require('./bnote'); | import BNote from "./bnote.js"; | ||||||
| import BBranch = require('./bbranch'); | import BBranch from "./bbranch.js"; | ||||||
|  | import noteService from "../../services/notes.js"; | ||||||
| 
 | 
 | ||||||
| const attachmentRoleToNoteTypeMapping = { | const attachmentRoleToNoteTypeMapping = { | ||||||
|     'image': 'image', |     'image': 'image', | ||||||
| @ -157,8 +158,6 @@ class BAttachment extends AbstractBeccaEntity<BAttachment> { | |||||||
|             throw new Error(`Cannot convert protected attachment outside of protected session`); |             throw new Error(`Cannot convert protected attachment outside of protected session`); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const noteService = require('../../services/notes'); |  | ||||||
| 
 |  | ||||||
|         const { note, branch } = noteService.createNewNote({ |         const { note, branch } = noteService.createNewNote({ | ||||||
|             parentNoteId: this.ownerId, |             parentNoteId: this.ownerId, | ||||||
|             title: this.title, |             title: this.title, | ||||||
| @ -249,4 +248,4 @@ class BAttachment extends AbstractBeccaEntity<BAttachment> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BAttachment; | export default BAttachment; | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import BNote = require('./bnote'); | import BNote from "./bnote.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import promotedAttributeDefinitionParser = require('../../services/promoted_attribute_definition_parser'); | import promotedAttributeDefinitionParser from "../../services/promoted_attribute_definition_parser.js"; | ||||||
| import sanitizeAttributeName = require('../../services/sanitize_attribute_name'); | import sanitizeAttributeName from "../../services/sanitize_attribute_name.js"; | ||||||
| import { AttributeRow, AttributeType } from './rows'; | import { AttributeRow, AttributeType } from './rows'; | ||||||
| 
 | 
 | ||||||
| interface SavingOpts { | interface SavingOpts { | ||||||
| @ -226,4 +226,4 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BAttribute; | export default BAttribute; | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import AbstractBeccaEntity = require("./abstract_becca_entity"); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| import { BlobRow } from "./rows"; | import { BlobRow } from "./rows"; | ||||||
| 
 | 
 | ||||||
| // TODO: Why this does not extend the abstract becca?
 | // TODO: Why this does not extend the abstract becca?
 | ||||||
| @ -37,4 +37,4 @@ class BBlob extends AbstractBeccaEntity<BBlob> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BBlob; | export default BBlob; | ||||||
|  | |||||||
| @ -1,13 +1,14 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import BNote = require('./bnote'); | import BNote from "./bnote.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext from "../../services/task_context.js"; | ||||||
| import cls = require('../../services/cls'); | import cls from "../../services/cls.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import { BranchRow } from './rows'; | import { BranchRow } from './rows'; | ||||||
|  | import handlers from "../../services/handlers.js"; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple |  * Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple | ||||||
| @ -157,7 +158,6 @@ class BBranch extends AbstractBeccaEntity<BBranch> { | |||||||
| 
 | 
 | ||||||
|             if (parentBranches.length === 1 && parentBranches[0] === this) { |             if (parentBranches.length === 1 && parentBranches[0] === this) { | ||||||
|                 // needs to be run before branches and attributes are deleted and thus attached relations disappear
 |                 // needs to be run before branches and attributes are deleted and thus attached relations disappear
 | ||||||
|                 const handlers = require('../../services/handlers'); |  | ||||||
|                 handlers.runAttachedRelations(note, 'runOnNoteDeletion', note); |                 handlers.runAttachedRelations(note, 'runOnNoteDeletion', note); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @ -285,4 +285,4 @@ class BBranch extends AbstractBeccaEntity<BBranch> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BBranch; | export default BBranch; | ||||||
|  | |||||||
| @ -2,8 +2,8 @@ | |||||||
| 
 | 
 | ||||||
| import { EtapiTokenRow } from "./rows"; | import { EtapiTokenRow } from "./rows"; | ||||||
| 
 | 
 | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * EtapiToken is an entity representing token used to authenticate against Trilium REST API from client applications. |  * EtapiToken is an entity representing token used to authenticate against Trilium REST API from client applications. | ||||||
| @ -80,4 +80,4 @@ class BEtapiToken extends AbstractBeccaEntity<BEtapiToken> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BEtapiToken; | export default BEtapiToken; | ||||||
|  | |||||||
| @ -1,21 +1,25 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService from "../../services/protected_session.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| import BRevision = require('./brevision'); | import BRevision from "./brevision.js"; | ||||||
| import BAttachment = require('./battachment'); | import BAttachment from "./battachment.js"; | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext from "../../services/task_context.js"; | ||||||
| import dayjs = require("dayjs"); | import dayjs from "dayjs"; | ||||||
| import utc = require('dayjs/plugin/utc'); | import utc from "dayjs/plugin/utc"; | ||||||
| import eventService = require('../../services/events'); | import eventService from "../../services/events.js"; | ||||||
| import { AttachmentRow, NoteRow, NoteType, RevisionRow } from './rows'; | import { AttachmentRow, AttributeType, NoteRow, NoteType, RevisionRow } from './rows'; | ||||||
| import BBranch = require('./bbranch'); | import BBranch from "./bbranch.js"; | ||||||
| import BAttribute = require('./battribute'); | import BAttribute from "./battribute.js"; | ||||||
| import { NotePojo } from '../becca-interface'; | import { NotePojo } from '../becca-interface'; | ||||||
|  | import searchService from "../../services/search/services/search.js"; | ||||||
|  | import cloningService, { CloneResponse } from "../../services/cloning.js"; | ||||||
|  | import noteService from "../../services/notes.js"; | ||||||
|  | import handlers from "../../services/handlers.js"; | ||||||
| dayjs.extend(utc); | dayjs.extend(utc); | ||||||
| 
 | 
 | ||||||
| const LABEL = 'label'; | const LABEL = 'label'; | ||||||
| @ -890,11 +894,9 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             const searchService = require('../../services/search/services/search'); |             const result = searchService.searchFromNote(this); | ||||||
|             const {searchResultNoteIds} = searchService.searchFromNote(this); |  | ||||||
| 
 |  | ||||||
|             const becca = this.becca; |             const becca = this.becca; | ||||||
|             return (searchResultNoteIds as string[])    // TODO: remove cast once search is converted
 |             return (result.searchResultNoteIds) | ||||||
|                 .map(resultNoteId => becca.notes[resultNoteId]) |                 .map(resultNoteId => becca.notes[resultNoteId]) | ||||||
|                 .filter(note => !!note); |                 .filter(note => !!note); | ||||||
|         } |         } | ||||||
| @ -1261,7 +1263,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|      * @param name - attribute name |      * @param name - attribute name | ||||||
|      * @param value - attribute value (optional) |      * @param value - attribute value (optional) | ||||||
|      */ |      */ | ||||||
|     setAttribute(type: string, name: string, value?: string) { |     setAttribute(type: AttributeType, name: string, value?: string) { | ||||||
|         const attributes = this.getOwnedAttributes(); |         const attributes = this.getOwnedAttributes(); | ||||||
|         const attr = attributes.find(attr => attr.type === type && attr.name === name); |         const attr = attributes.find(attr => attr.type === type && attr.name === name); | ||||||
| 
 | 
 | ||||||
| @ -1274,8 +1276,6 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         else { |         else { | ||||||
|             const BAttribute = require('./battribute'); |  | ||||||
| 
 |  | ||||||
|             new BAttribute({ |             new BAttribute({ | ||||||
|                 noteId: this.noteId, |                 noteId: this.noteId, | ||||||
|                 type: type, |                 type: type, | ||||||
| @ -1310,9 +1310,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|      * @param name - name of the attribute, not including the leading ~/# |      * @param name - name of the attribute, not including the leading ~/# | ||||||
|      * @param value - value of the attribute - text for labels, target note ID for relations; optional. |      * @param value - value of the attribute - text for labels, target note ID for relations; optional. | ||||||
|      */ |      */ | ||||||
|     addAttribute(type: string, name: string, value: string = "", isInheritable: boolean = false, position: number | null = null): BAttribute { |     addAttribute(type: AttributeType, name: string, value: string = "", isInheritable: boolean = false, position: number | null = null): BAttribute { | ||||||
|         const BAttribute = require('./battribute'); |  | ||||||
| 
 |  | ||||||
|         return new BAttribute({ |         return new BAttribute({ | ||||||
|             noteId: this.noteId, |             noteId: this.noteId, | ||||||
|             type: type, |             type: type, | ||||||
| @ -1351,7 +1349,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|      * @param name - attribute name |      * @param name - attribute name | ||||||
|      * @param value - attribute value (optional) |      * @param value - attribute value (optional) | ||||||
|      */ |      */ | ||||||
|     toggleAttribute(type: string, enabled: boolean, name: string, value?: string) { |     toggleAttribute(type: AttributeType, enabled: boolean, name: string, value?: string) { | ||||||
|         if (enabled) { |         if (enabled) { | ||||||
|             this.setAttribute(type, name, value); |             this.setAttribute(type, name, value); | ||||||
|         } |         } | ||||||
| @ -1423,8 +1421,6 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     searchNotesInSubtree(searchString: string) { |     searchNotesInSubtree(searchString: string) { | ||||||
|         const searchService = require('../../services/search/services/search'); |  | ||||||
| 
 |  | ||||||
|         return searchService.searchNotes(searchString) as BNote[]; |         return searchService.searchNotes(searchString) as BNote[]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1432,12 +1428,16 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|         return this.searchNotesInSubtree(searchString)[0]; |         return this.searchNotesInSubtree(searchString)[0]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     cloneTo(parentNoteId: string) { |     cloneTo(parentNoteId: string): CloneResponse { | ||||||
|         const cloningService = require('../../services/cloning'); |  | ||||||
| 
 |  | ||||||
|         const branch = this.becca.getNote(parentNoteId)?.getParentBranches()[0]; |         const branch = this.becca.getNote(parentNoteId)?.getParentBranches()[0]; | ||||||
|  |         if (!branch?.branchId) { | ||||||
|  |             return { | ||||||
|  |                 success: false, | ||||||
|  |                 message: "Unable to find the branch ID to clone." | ||||||
|  |             }; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         return cloningService.cloneNoteToBranch(this.noteId, branch?.branchId); |         return cloningService.cloneNoteToBranch(this.noteId, branch.branchId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     isEligibleForConversionToAttachment(opts: ConvertOpts = { autoConversion: false }) { |     isEligibleForConversionToAttachment(opts: ConvertOpts = { autoConversion: false }) { | ||||||
| @ -1508,7 +1508,6 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
| 
 | 
 | ||||||
|         parentNote.setContent(fixedContent); |         parentNote.setContent(fixedContent); | ||||||
| 
 | 
 | ||||||
|         const noteService = require('../../services/notes'); |  | ||||||
|         noteService.asyncPostProcessContent(parentNote, fixedContent); // to mark an unused attachment for deletion
 |         noteService.asyncPostProcessContent(parentNote, fixedContent); // to mark an unused attachment for deletion
 | ||||||
| 
 | 
 | ||||||
|         this.deleteNote(); |         this.deleteNote(); | ||||||
| @ -1535,7 +1534,6 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // needs to be run before branches and attributes are deleted and thus attached relations disappear
 |         // needs to be run before branches and attributes are deleted and thus attached relations disappear
 | ||||||
|         const handlers = require('../../services/handlers'); |  | ||||||
|         handlers.runAttachedRelations(this, 'runOnNoteDeletion', this); |         handlers.runAttachedRelations(this, 'runOnNoteDeletion', this); | ||||||
|         taskContext.noteDeletionHandlerTriggered = true; |         taskContext.noteDeletionHandlerTriggered = true; | ||||||
| 
 | 
 | ||||||
| @ -1696,4 +1694,4 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BNote; | export default BNote; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| import { OptionRow } from './rows'; | import { OptionRow } from './rows'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -48,4 +48,4 @@ class BOption extends AbstractBeccaEntity<BOption> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BOption; | export default BOption; | ||||||
|  | |||||||
| @ -2,8 +2,8 @@ | |||||||
| 
 | 
 | ||||||
| import { RecentNoteRow } from "./rows"; | import { RecentNoteRow } from "./rows"; | ||||||
| 
 | 
 | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * RecentNote represents recently visited note. |  * RecentNote represents recently visited note. | ||||||
| @ -38,4 +38,4 @@ class BRecentNote extends AbstractBeccaEntity<BRecentNote> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BRecentNote; | export default BRecentNote; | ||||||
|  | |||||||
| @ -1,13 +1,14 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService from "../../services/protected_session.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import becca = require('../becca'); | import becca from "../becca.js"; | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity'); | import AbstractBeccaEntity from "./abstract_becca_entity.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import BAttachment = require('./battachment'); | import BAttachment from "./battachment.js"; | ||||||
| import { AttachmentRow, RevisionRow } from './rows'; | import { AttachmentRow, RevisionRow } from './rows'; | ||||||
|  | import eraseService from "../../services/erase.js"; | ||||||
| 
 | 
 | ||||||
| interface ContentOpts { | interface ContentOpts { | ||||||
|     /** will also save this BRevision entity */ |     /** will also save this BRevision entity */ | ||||||
| @ -164,7 +165,9 @@ class BRevision extends AbstractBeccaEntity<BRevision> { | |||||||
|      * Revisions are not soft-deletable, they are immediately hard-deleted (erased). |      * Revisions are not soft-deletable, they are immediately hard-deleted (erased). | ||||||
|      */ |      */ | ||||||
|     eraseRevision() { |     eraseRevision() { | ||||||
|         require("../../services/erase.js").eraseRevisions([this.revisionId]); |         if (this.revisionId) { | ||||||
|  |             eraseService.eraseRevisions([this.revisionId]); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     beforeSaving() { |     beforeSaving() { | ||||||
| @ -211,4 +214,4 @@ class BRevision extends AbstractBeccaEntity<BRevision> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = BRevision; | export default BRevision; | ||||||
|  | |||||||
| @ -42,7 +42,7 @@ export interface OptionRow { | |||||||
|     name: string; |     name: string; | ||||||
|     value: string; |     value: string; | ||||||
|     isSynced: boolean; |     isSynced: boolean; | ||||||
|     utcDateModified: string; |     utcDateModified?: string; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface EtapiTokenRow { | export interface EtapiTokenRow { | ||||||
| @ -69,7 +69,7 @@ export interface AttributeRow { | |||||||
|     noteId?: string; |     noteId?: string; | ||||||
|     type: AttributeType; |     type: AttributeType; | ||||||
|     name: string; |     name: string; | ||||||
|     position?: number; |     position?: number | null; | ||||||
|     value?: string; |     value?: string; | ||||||
|     isInheritable?: boolean; |     isInheritable?: boolean; | ||||||
|     utcDateModified?: string; |     utcDateModified?: string; | ||||||
|  | |||||||
| @ -1,14 +1,14 @@ | |||||||
| import { ConstructorData } from './becca-interface'; | import { ConstructorData } from './becca-interface'; | ||||||
| import AbstractBeccaEntity = require('./entities/abstract_becca_entity'); | import AbstractBeccaEntity from "./entities/abstract_becca_entity.js"; | ||||||
| import BAttachment = require('./entities/battachment'); | import BAttachment from "./entities/battachment.js"; | ||||||
| import BAttribute = require('./entities/battribute'); | import BAttribute from "./entities/battribute.js"; | ||||||
| import BBlob = require('./entities/bblob'); | import BBlob from "./entities/bblob.js"; | ||||||
| import BBranch = require('./entities/bbranch'); | import BBranch from "./entities/bbranch.js"; | ||||||
| import BEtapiToken = require('./entities/betapi_token'); | import BEtapiToken from "./entities/betapi_token.js"; | ||||||
| import BNote = require('./entities/bnote'); | import BNote from "./entities/bnote.js"; | ||||||
| import BOption = require('./entities/boption'); | import BOption from "./entities/boption.js"; | ||||||
| import BRecentNote = require('./entities/brecent_note'); | import BRecentNote from "./entities/brecent_note.js"; | ||||||
| import BRevision = require('./entities/brevision'); | import BRevision from "./entities/brevision.js"; | ||||||
| 
 | 
 | ||||||
| type EntityClass = new (row?: any) => AbstractBeccaEntity<any>; | type EntityClass = new (row?: any) => AbstractBeccaEntity<any>; | ||||||
| 
 | 
 | ||||||
| @ -32,6 +32,6 @@ function getEntityFromEntityName(entityName: keyof typeof ENTITY_NAME_TO_ENTITY) | |||||||
|     return ENTITY_NAME_TO_ENTITY[entityName]; |     return ENTITY_NAME_TO_ENTITY[entityName]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getEntityFromEntityName |     getEntityFromEntityName | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| import becca = require('./becca'); | import becca from "./becca.js"; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| import beccaService = require('./becca_service'); | import beccaService from "./becca_service.js"; | ||||||
| import dateUtils = require('../services/date_utils'); | import dateUtils from "../services/date_utils.js"; | ||||||
| import { JSDOM } from "jsdom"; | import { JSDOM } from "jsdom"; | ||||||
| import BNote = require('./entities/bnote'); | import BNote from "./entities/bnote.js"; | ||||||
| 
 | 
 | ||||||
| const DEBUG = false; | const DEBUG = false; | ||||||
| 
 | 
 | ||||||
| @ -461,6 +461,6 @@ function setImmediatePromise() { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     findSimilarNotes |     findSimilarNotes | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -6,4 +6,4 @@ class NotFoundError { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = NotFoundError; | export default NotFoundError; | ||||||
| @ -6,4 +6,4 @@ class ValidationError { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = ValidationError; | export default ValidationError; | ||||||
| @ -1,6 +1,6 @@ | |||||||
| import { Router } from 'express'; | import { Router } from 'express'; | ||||||
| import appInfo = require('../services/app_info'); | import appInfo from "../services/app_info.js"; | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| 
 | 
 | ||||||
| function register(router: Router) { | function register(router: Router) { | ||||||
|     eu.route(router, 'get', '/etapi/app-info', (req, res, next) => { |     eu.route(router, 'get', '/etapi/app-info', (req, res, next) => { | ||||||
| @ -8,6 +8,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| import becca = require('../becca/becca'); | import becca from "../becca/becca.js"; | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| import mappers = require('./mappers'); | import mappers from "./mappers.js"; | ||||||
| import v = require('./validators'); | import v from "./validators.js"; | ||||||
| import utils = require('../services/utils'); | import utils from "../services/utils.js"; | ||||||
| import { Router } from 'express'; | import { Router } from 'express'; | ||||||
| import { AttachmentRow } from '../becca/entities/rows'; | import { AttachmentRow } from '../becca/entities/rows'; | ||||||
| import { ValidatorMap } from './etapi-interface'; | import { ValidatorMap } from './etapi-interface'; | ||||||
| @ -104,6 +104,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| import becca = require('../becca/becca'); | import becca from "../becca/becca.js"; | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| import mappers = require('./mappers'); | import mappers from "./mappers.js"; | ||||||
| import attributeService = require('../services/attributes'); | import attributeService from "../services/attributes.js"; | ||||||
| import v = require('./validators'); | import v from "./validators.js"; | ||||||
| import { Router } from 'express'; | import { Router } from 'express'; | ||||||
| import { AttributeRow } from '../becca/entities/rows'; | import { AttributeRow } from '../becca/entities/rows'; | ||||||
| import { ValidatorMap } from './etapi-interface'; | import { ValidatorMap } from './etapi-interface'; | ||||||
| @ -81,6 +81,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import becca = require('../becca/becca'); | import becca from "../becca/becca.js"; | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| import passwordEncryptionService = require('../services/encryption/password_encryption'); | import passwordEncryptionService from "../services/encryption/password_encryption.js"; | ||||||
| import etapiTokenService = require('../services/etapi_tokens'); | import etapiTokenService from "../services/etapi_tokens.js"; | ||||||
| import { RequestHandler, Router } from 'express'; | import { RequestHandler, Router } from 'express'; | ||||||
| 
 | 
 | ||||||
| function register(router: Router, loginMiddleware: RequestHandler[]) { | function register(router: Router, loginMiddleware: RequestHandler[]) { | ||||||
| @ -39,6 +39,6 @@ function register(router: Router, loginMiddleware: RequestHandler[]) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import { Router } from "express"; | import { Router } from "express"; | ||||||
| 
 | 
 | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| import backupService = require('../services/backup'); | import backupService from "../services/backup.js"; | ||||||
| 
 | 
 | ||||||
| function register(router: Router) { | function register(router: Router) { | ||||||
|     eu.route(router, 'put', '/etapi/backup/:backupName', async (req, res, next) => { |     eu.route(router, 'put', '/etapi/backup/:backupName', async (req, res, next) => { | ||||||
| @ -11,6 +11,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| import { Router } from "express"; | import { Router } from "express"; | ||||||
| 
 | 
 | ||||||
| import becca = require('../becca/becca'); | import becca from "../becca/becca.js"; | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| import mappers = require('./mappers'); | import mappers from "./mappers.js"; | ||||||
| import BBranch = require('../becca/entities/bbranch'); | import BBranch from "../becca/entities/bbranch.js"; | ||||||
| import entityChangesService = require('../services/entity_changes'); | import entityChangesService from "../services/entity_changes.js"; | ||||||
| import v = require('./validators'); | import v from "./validators.js"; | ||||||
| import { BranchRow } from "../becca/entities/rows"; | import { BranchRow } from "../becca/entities/rows"; | ||||||
| 
 | 
 | ||||||
| function register(router: Router) { | function register(router: Router) { | ||||||
| @ -84,6 +84,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| import cls = require('../services/cls'); | import cls from "../services/cls.js"; | ||||||
| import sql = require('../services/sql'); | import sql from "../services/sql.js"; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| import becca = require('../becca/becca'); | import becca from "../becca/becca.js"; | ||||||
| import etapiTokenService = require('../services/etapi_tokens'); | import etapiTokenService from "../services/etapi_tokens.js"; | ||||||
| import config = require('../services/config'); | import config from "../services/config.js"; | ||||||
| import { NextFunction, Request, RequestHandler, Response, Router } from 'express'; | import { NextFunction, Request, RequestHandler, Response, Router } from 'express'; | ||||||
| import { AppRequest, AppRequestHandler } from '../routes/route-interface'; | import { AppRequest, AppRequestHandler } from '../routes/route-interface'; | ||||||
| import { ValidatorMap } from './etapi-interface'; | import { ValidatorMap } from './etapi-interface'; | ||||||
| @ -146,7 +146,7 @@ function validateAndPatch(target: any, source: any, allowedProperties: Validator | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     EtapiError, |     EtapiError, | ||||||
|     sendError, |     sendError, | ||||||
|     route, |     route, | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import BAttachment = require("../becca/entities/battachment"); | import BAttachment from "../becca/entities/battachment.js"; | ||||||
| import BAttribute = require("../becca/entities/battribute"); | import BAttribute from "../becca/entities/battribute.js"; | ||||||
| import BBranch = require("../becca/entities/bbranch"); | import BBranch from "../becca/entities/bbranch.js"; | ||||||
| import BNote = require("../becca/entities/bnote"); | import BNote from "../becca/entities/bnote.js"; | ||||||
| 
 | 
 | ||||||
| function mapNoteToPojo(note: BNote) { | function mapNoteToPojo(note: BNote) { | ||||||
|     return { |     return { | ||||||
| @ -64,7 +64,7 @@ function mapAttachmentToPojo(attachment: BAttachment) { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     mapNoteToPojo, |     mapNoteToPojo, | ||||||
|     mapBranchToPojo, |     mapBranchToPojo, | ||||||
|     mapAttributeToPojo, |     mapAttributeToPojo, | ||||||
|  | |||||||
| @ -1,19 +1,19 @@ | |||||||
| import becca = require('../becca/becca'); | import becca from "../becca/becca.js"; | ||||||
| import utils = require('../services/utils'); | import utils from "../services/utils.js"; | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| import mappers = require('./mappers'); | import mappers from "./mappers.js"; | ||||||
| import noteService = require('../services/notes'); | import noteService from "../services/notes.js"; | ||||||
| import TaskContext = require('../services/task_context'); | import TaskContext from "../services/task_context.js"; | ||||||
| import v = require('./validators'); | import v from "./validators.js"; | ||||||
| import searchService = require('../services/search/services/search'); | import searchService from "../services/search/services/search.js"; | ||||||
| import SearchContext = require('../services/search/search_context'); | import SearchContext from "../services/search/search_context.js"; | ||||||
| import zipExportService = require('../services/export/zip'); | import zipExportService from "../services/export/zip.js"; | ||||||
| import zipImportService = require('../services/import/zip'); | import zipImportService from "../services/import/zip.js"; | ||||||
| import { Router } from 'express'; | import { Router } from 'express'; | ||||||
| import { AppRequest } from '../routes/route-interface'; | import { AppRequest } from '../routes/route-interface'; | ||||||
| import { ParsedQs } from 'qs'; | import { ParsedQs } from 'qs'; | ||||||
| import { NoteParams } from '../services/note-interface'; | import { NoteParams } from '../services/note-interface'; | ||||||
| import BNote = require('../becca/entities/bnote'); | import BNote from "../becca/entities/bnote.js"; | ||||||
| import { SearchParams } from '../services/search/services/types'; | import { SearchParams } from '../services/search/services/types'; | ||||||
| import { ValidatorMap } from './etapi-interface'; | import { ValidatorMap } from './etapi-interface'; | ||||||
| 
 | 
 | ||||||
| @ -267,6 +267,6 @@ function parseInteger(obj: any, name: string) { | |||||||
|     return integer; |     return integer; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import { Router } from "express"; | import { Router } from "express"; | ||||||
| 
 | 
 | ||||||
| import fs = require('fs'); | import fs from "fs"; | ||||||
| import path = require('path'); | import path from "path"; | ||||||
| 
 | 
 | ||||||
| const specPath = path.join(__dirname, 'etapi.openapi.yaml'); | const specPath = path.join(__dirname, 'etapi.openapi.yaml'); | ||||||
| let spec: string | null = null; | let spec: string | null = null; | ||||||
| @ -17,6 +17,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import specialNotesService = require('../services/special_notes'); | import specialNotesService from "../services/special_notes.js"; | ||||||
| import dateNotesService = require('../services/date_notes'); | import dateNotesService from "../services/date_notes.js"; | ||||||
| import eu = require('./etapi_utils'); | import eu from "./etapi_utils.js"; | ||||||
| import mappers = require('./mappers'); | import mappers from "./mappers.js"; | ||||||
| import { Router } from 'express'; | import { Router } from 'express'; | ||||||
| 
 | 
 | ||||||
| const getDateInvalidError = (date: string) => new eu.EtapiError(400, "DATE_INVALID", `Date "${date}" is not valid.`); | const getDateInvalidError = (date: string) => new eu.EtapiError(400, "DATE_INVALID", `Date "${date}" is not valid.`); | ||||||
| @ -73,6 +73,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import noteTypeService = require('../services/note_types'); | import noteTypeService from "../services/note_types.js"; | ||||||
| import dateUtils = require('../services/date_utils'); | import dateUtils from "../services/date_utils.js"; | ||||||
| 
 | 
 | ||||||
| function mandatory(obj: unknown) { | function mandatory(obj: unknown) { | ||||||
|     if (obj === undefined) { |     if (obj === undefined) { | ||||||
| @ -107,7 +107,7 @@ function isValidEntityId(obj: unknown) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     mandatory, |     mandatory, | ||||||
|     notNull, |     notNull, | ||||||
|     isString, |     isString, | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import appInfo = require('../../services/app_info'); | import appInfo from "../../services/app_info.js"; | ||||||
| 
 | 
 | ||||||
| function getAppInfo() { | function getAppInfo() { | ||||||
|     return appInfo; |     return appInfo; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getAppInfo |     getAppInfo | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import blobService = require('../../services/blob'); | import blobService from "../../services/blob.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import imageService = require("../../services/image"); | import imageService from "../../services/image.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function getAttachmentBlob(req: Request) { | function getAttachmentBlob(req: Request) { | ||||||
| @ -97,7 +97,7 @@ function convertAttachmentToNote(req: Request) { | |||||||
|     return attachment.convertToNote(); |     return attachment.convertToNote(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getAttachmentBlob, |     getAttachmentBlob, | ||||||
|     getAttachments, |     getAttachments, | ||||||
|     getAttachment, |     getAttachment, | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import attributeService = require('../../services/attributes'); | import attributeService from "../../services/attributes.js"; | ||||||
| import BAttribute = require('../../becca/entities/battribute'); | import BAttribute from "../../becca/entities/battribute.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function getEffectiveNoteAttributes(req: Request) { | function getEffectiveNoteAttributes(req: Request) { | ||||||
| @ -238,7 +238,7 @@ function deleteRelation(req: Request) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     updateNoteAttributes, |     updateNoteAttributes, | ||||||
|     updateNoteAttribute, |     updateNoteAttribute, | ||||||
|     setNoteAttribute, |     setNoteAttribute, | ||||||
|  | |||||||
| @ -1,13 +1,13 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import beccaService = require('../../becca/becca_service'); | import beccaService from "../../becca/becca_service.js"; | ||||||
| import searchService = require('../../services/search/services/search'); | import searchService from "../../services/search/services/search.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import cls = require('../../services/cls'); | import cls from "../../services/cls.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| 
 | 
 | ||||||
| function getAutocomplete(req: Request) { | function getAutocomplete(req: Request) { | ||||||
|     if (typeof req.query.query !== "string") { |     if (typeof req.query.query !== "string") { | ||||||
| @ -75,6 +75,6 @@ function getRecentNotes(activeNoteId: string) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getAutocomplete |     getAutocomplete | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import fs = require('fs'); | import fs from "fs"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import dataDir = require('../../services/data_dir'); | import dataDir from "../../services/data_dir.js"; | ||||||
| const { LOG_DIR } = dataDir; | const { LOG_DIR } = dataDir; | ||||||
| 
 | 
 | ||||||
| function getBackendLog() { | function getBackendLog() { | ||||||
| @ -17,6 +17,6 @@ function getBackendLog() { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getBackendLog |     getBackendLog | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,16 +1,16 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import entityChangesService = require('../../services/entity_changes'); | import entityChangesService from "../../services/entity_changes.js"; | ||||||
| import treeService = require('../../services/tree'); | import treeService from "../../services/tree.js"; | ||||||
| import eraseService = require('../../services/erase'); | import eraseService from "../../services/erase.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext from "../../services/task_context.js"; | ||||||
| import branchService = require('../../services/branches'); | import branchService from "../../services/branches.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import eventService = require("../../services/events"); | import eventService from "../../services/events.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -224,7 +224,7 @@ function setPrefix(req: Request) { | |||||||
|     branch.save(); |     branch.save(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     moveBranchToParent, |     moveBranchToParent, | ||||||
|     moveBranchBeforeNote, |     moveBranchBeforeNote, | ||||||
|     moveBranchAfterNote, |     moveBranchAfterNote, | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import bulkActionService = require('../../services/bulk_actions'); | import bulkActionService from "../../services/bulk_actions.js"; | ||||||
| 
 | 
 | ||||||
| function execute(req: Request) { | function execute(req: Request) { | ||||||
|     const {noteIds, includeDescendants} = req.body; |     const {noteIds, includeDescendants} = req.body; | ||||||
| @ -43,7 +43,7 @@ function getAffectedNoteIds(noteIds: string[], includeDescendants: boolean) { | |||||||
|     return affectedNoteIds; |     return affectedNoteIds; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     execute, |     execute, | ||||||
|     getAffectedNoteCount |     getAffectedNoteCount | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -2,22 +2,22 @@ | |||||||
| 
 | 
 | ||||||
| import { Request } from "express"; | import { Request } from "express"; | ||||||
| 
 | 
 | ||||||
| import attributeService = require('../../services/attributes'); | import attributeService from "../../services/attributes.js"; | ||||||
| import cloneService = require('../../services/cloning'); | import cloneService from "../../services/cloning.js"; | ||||||
| import noteService = require('../../services/notes'); | import noteService from "../../services/notes.js"; | ||||||
| import dateNoteService = require('../../services/date_notes'); | import dateNoteService from "../../services/date_notes.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import imageService = require('../../services/image'); | import imageService from "../../services/image.js"; | ||||||
| import appInfo = require('../../services/app_info'); | import appInfo from "../../services/app_info.js"; | ||||||
| import ws = require('../../services/ws'); | import ws from "../../services/ws.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import path = require('path'); | import path from "path"; | ||||||
| import htmlSanitizer = require('../../services/html_sanitizer'); | import htmlSanitizer from "../../services/html_sanitizer.js"; | ||||||
| import attributeFormatter = require('../../services/attribute_formatter'); | import attributeFormatter from "../../services/attribute_formatter.js"; | ||||||
| import jsdom = require("jsdom"); | import jsdom from "jsdom"; | ||||||
| import BNote = require("../../becca/entities/bnote"); | import BNote from "../../becca/entities/bnote.js"; | ||||||
| import ValidationError = require("../../errors/validation_error"); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| const { JSDOM } = jsdom; | const { JSDOM } = jsdom; | ||||||
| 
 | 
 | ||||||
| interface Image { | interface Image { | ||||||
| @ -229,7 +229,7 @@ function findNotesByUrl(req: Request){ | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     createNote, |     createNote, | ||||||
|     addClipping, |     addClipping, | ||||||
|     openNote, |     openNote, | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import cloningService = require('../../services/cloning'); | import cloningService from "../../services/cloning.js"; | ||||||
| 
 | 
 | ||||||
| function cloneNoteToBranch(req: Request) { | function cloneNoteToBranch(req: Request) { | ||||||
|     const {noteId, parentBranchId} = req.params; |     const {noteId, parentBranchId} = req.params; | ||||||
| @ -29,7 +29,7 @@ function toggleNoteInParent(req: Request) { | |||||||
|     return cloningService.toggleNoteInParent(present === 'true', noteId, parentNoteId); |     return cloningService.toggleNoteInParent(present === 'true', noteId, parentNoteId); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     cloneNoteToBranch, |     cloneNoteToBranch, | ||||||
|     cloneNoteToParentNote, |     cloneNoteToParentNote, | ||||||
|     cloneNoteAfter, |     cloneNoteAfter, | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import backupService = require('../../services/backup'); | import backupService from "../../services/backup.js"; | ||||||
| import anonymizationService = require('../../services/anonymization'); | import anonymizationService from "../../services/anonymization.js"; | ||||||
| import consistencyChecksService = require('../../services/consistency_checks'); | import consistencyChecksService from "../../services/consistency_checks.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| 
 | 
 | ||||||
| function getExistingBackups() { | function getExistingBackups() { | ||||||
|     return backupService.getExistingBackups(); |     return backupService.getExistingBackups(); | ||||||
| @ -49,7 +49,7 @@ function checkIntegrity() { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getExistingBackups, |     getExistingBackups, | ||||||
|     backupDatabase, |     backupDatabase, | ||||||
|     vacuumDatabase, |     vacuumDatabase, | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import etapiTokenService = require('../../services/etapi_tokens'); | import etapiTokenService from "../../services/etapi_tokens.js"; | ||||||
| 
 | 
 | ||||||
| function getTokens() { | function getTokens() { | ||||||
|     const tokens = etapiTokenService.getTokens(); |     const tokens = etapiTokenService.getTokens(); | ||||||
| @ -21,7 +21,7 @@ function deleteToken(req: Request) { | |||||||
|     etapiTokenService.deleteToken(req.params.etapiTokenId); |     etapiTokenService.deleteToken(req.params.etapiTokenId); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getTokens, |     getTokens, | ||||||
|     createToken, |     createToken, | ||||||
|     patchToken, |     patchToken, | ||||||
|  | |||||||
| @ -1,14 +1,14 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import zipExportService = require('../../services/export/zip'); | import zipExportService from "../../services/export/zip.js"; | ||||||
| import singleExportService = require('../../services/export/single'); | import singleExportService from "../../services/export/single.js"; | ||||||
| import opmlExportService = require('../../services/export/opml'); | import opmlExportService from "../../services/export/opml.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext from "../../services/task_context.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import NotFoundError = require('../../errors/not_found_error'); | import NotFoundError from "../../errors/not_found_error.js"; | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| 
 | 
 | ||||||
| function exportBranch(req: Request, res: Response) { | function exportBranch(req: Request, res: Response) { | ||||||
|     const {branchId, type, format, version, taskId} = req.params; |     const {branchId, type, format, version, taskId} = req.params; | ||||||
| @ -55,6 +55,6 @@ function exportBranch(req: Request, res: Response) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     exportBranch |     exportBranch | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,19 +1,19 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService from "../../services/protected_session.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import noteService = require('../../services/notes'); | import noteService from "../../services/notes.js"; | ||||||
| import tmp = require('tmp'); | import tmp from "tmp"; | ||||||
| import fs = require('fs'); | import fs from "fs"; | ||||||
| import { Readable } from 'stream'; | import { Readable } from 'stream'; | ||||||
| import chokidar = require('chokidar'); | import chokidar from "chokidar"; | ||||||
| import ws = require('../../services/ws'); | import ws from "../../services/ws.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| import BNote = require('../../becca/entities/bnote'); | import BNote from "../../becca/entities/bnote.js"; | ||||||
| import BAttachment = require('../../becca/entities/battachment'); | import BAttachment from "../../becca/entities/battachment.js"; | ||||||
| import { AppRequest } from '../route-interface'; | import { AppRequest } from '../route-interface'; | ||||||
| 
 | 
 | ||||||
| function updateFile(req: AppRequest) { | function updateFile(req: AppRequest) { | ||||||
| @ -245,7 +245,7 @@ function uploadModifiedFileToAttachment(req: Request) { | |||||||
|     attachment.setContent(fileContent); |     attachment.setContent(fileContent); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     updateFile, |     updateFile, | ||||||
|     updateAttachment, |     updateAttachment, | ||||||
|     openFile, |     openFile, | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| import optionService = require('../../services/options'); | import optionService from "../../services/options.js"; | ||||||
| 
 | 
 | ||||||
| function getFontCss(req: Request, res: Response) { | function getFontCss(req: Request, res: Response) { | ||||||
|     res.setHeader('Content-Type', 'text/css'); |     res.setHeader('Content-Type', 'text/css'); | ||||||
| @ -35,6 +35,6 @@ function getFontCss(req: Request, res: Response) { | |||||||
|     res.send(style); |     res.send(style); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getFontCss |     getFontCss | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,13 +1,13 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import imageService = require('../../services/image'); | import imageService from "../../services/image.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| const RESOURCE_DIR = require('../../services/resource_dir').RESOURCE_DIR; | import fs from "fs"; | ||||||
| import fs = require('fs'); |  | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| import BNote = require('../../becca/entities/bnote'); | import BNote from "../../becca/entities/bnote.js"; | ||||||
| import BRevision = require('../../becca/entities/brevision'); | import BRevision from "../../becca/entities/brevision.js"; | ||||||
| import { AppRequest } from '../route-interface'; | import { AppRequest } from '../route-interface'; | ||||||
|  | import { RESOURCE_DIR } from "../../services/resource_dir.js"; | ||||||
| 
 | 
 | ||||||
| function returnImageFromNote(req: Request, res: Response) { | function returnImageFromNote(req: Request, res: Response) { | ||||||
|     const image = becca.getNote(req.params.noteId); |     const image = becca.getNote(req.params.noteId); | ||||||
| @ -112,7 +112,7 @@ function updateImage(req: AppRequest) { | |||||||
|     return { uploaded: true }; |     return { uploaded: true }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     returnImageFromNote, |     returnImageFromNote, | ||||||
|     returnImageFromRevision, |     returnImageFromRevision, | ||||||
|     returnAttachedImage, |     returnAttachedImage, | ||||||
|  | |||||||
| @ -1,18 +1,18 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import enexImportService = require('../../services/import/enex'); | import enexImportService from "../../services/import/enex.js"; | ||||||
| import opmlImportService = require('../../services/import/opml'); | import opmlImportService from "../../services/import/opml.js"; | ||||||
| import zipImportService = require('../../services/import/zip'); | import zipImportService from "../../services/import/zip.js"; | ||||||
| import singleImportService = require('../../services/import/single'); | import singleImportService from "../../services/import/single.js"; | ||||||
| import cls = require('../../services/cls'); | import cls from "../../services/cls.js"; | ||||||
| import path = require('path'); | import path from "path"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import beccaLoader = require('../../becca/becca_loader'); | import beccaLoader from "../../becca/becca_loader.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext from "../../services/task_context.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import BNote = require('../../becca/entities/bnote'); | import BNote from "../../becca/entities/bnote.js"; | ||||||
| import { AppRequest } from '../route-interface'; | import { AppRequest } from '../route-interface'; | ||||||
| 
 | 
 | ||||||
| async function importNotesToBranch(req: AppRequest) { | async function importNotesToBranch(req: AppRequest) { | ||||||
| @ -136,7 +136,7 @@ async function importAttachmentsToNote(req: AppRequest) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     importNotesToBranch, |     importNotesToBranch, | ||||||
|     importAttachmentsToNote |     importAttachmentsToNote | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import keyboardActions = require('../../services/keyboard_actions'); | import keyboardActions from "../../services/keyboard_actions.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| 
 | 
 | ||||||
| function getKeyboardActions() { | function getKeyboardActions() { | ||||||
|     return keyboardActions.getKeyboardActions(); |     return keyboardActions.getKeyboardActions(); | ||||||
| @ -14,7 +14,7 @@ function getShortcutsForNotes() { | |||||||
|     return labels.filter(attr => becca.getNote(attr.noteId)?.type !== 'launcher'); |     return labels.filter(attr => becca.getNote(attr.noteId)?.type !== 'launcher'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getKeyboardActions, |     getKeyboardActions, | ||||||
|     getShortcutsForNotes |     getShortcutsForNotes | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,17 +1,17 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import options = require('../../services/options'); | import options from "../../services/options.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import instanceId = require('../../services/instance_id'); | import instanceId from "../../services/instance_id.js"; | ||||||
| import passwordEncryptionService = require('../../services/encryption/password_encryption'); | import passwordEncryptionService from "../../services/encryption/password_encryption.js"; | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService from "../../services/protected_session.js"; | ||||||
| import appInfo = require('../../services/app_info'); | import appInfo from "../../services/app_info.js"; | ||||||
| import eventService = require('../../services/events'); | import eventService from "../../services/events.js"; | ||||||
| import sqlInit = require('../../services/sql_init'); | import sqlInit from "../../services/sql_init.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import ws = require('../../services/ws'); | import ws from "../../services/ws.js"; | ||||||
| import etapiTokenService = require('../../services/etapi_tokens'); | import etapiTokenService from "../../services/etapi_tokens.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import { AppRequest } from '../route-interface'; | import { AppRequest } from '../route-interface'; | ||||||
| 
 | 
 | ||||||
| @ -110,7 +110,7 @@ function token(req: Request) { | |||||||
|     return { token: authToken }; |     return { token: authToken }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     loginSync, |     loginSync, | ||||||
|     loginToProtectedSession, |     loginToProtectedSession, | ||||||
|     logoutFromProtectedSession, |     logoutFromProtectedSession, | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import { JSDOM } from "jsdom"; | import { JSDOM } from "jsdom"; | ||||||
| import BNote = require('../../becca/entities/bnote'); | import BNote from "../../becca/entities/bnote.js"; | ||||||
| import BAttribute = require('../../becca/entities/battribute'); | import BAttribute from "../../becca/entities/battribute.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function buildDescendantCountMap(noteIdsToCount: string[]) { | function buildDescendantCountMap(noteIdsToCount: string[]) { | ||||||
| @ -384,7 +384,7 @@ function getBacklinks(req: Request) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getLinkMap, |     getLinkMap, | ||||||
|     getTreeMap, |     getTreeMap, | ||||||
|     getBacklinkCount, |     getBacklinkCount, | ||||||
|  | |||||||
| @ -1,17 +1,17 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import noteService = require('../../services/notes'); | import noteService from "../../services/notes.js"; | ||||||
| import eraseService = require('../../services/erase'); | import eraseService from "../../services/erase.js"; | ||||||
| import treeService = require('../../services/tree'); | import treeService from "../../services/tree.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext from "../../services/task_context.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import blobService = require('../../services/blob'); | import blobService from "../../services/blob.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import BBranch = require('../../becca/entities/bbranch'); | import BBranch from "../../becca/entities/bbranch.js"; | ||||||
| import { AttributeRow } from '../../becca/entities/rows'; | import { AttributeRow } from '../../becca/entities/rows'; | ||||||
| 
 | 
 | ||||||
| function getNote(req: Request) { | function getNote(req: Request) { | ||||||
| @ -250,7 +250,7 @@ function convertNoteToAttachment(req: Request) { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getNote, |     getNote, | ||||||
|     getNoteBlob, |     getNoteBlob, | ||||||
|     getNoteMetadata, |     getNoteMetadata, | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import optionService = require('../../services/options'); | import optionService from "../../services/options.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import searchService = require('../../services/search/services/search'); | import searchService from "../../services/search/services/search.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| // options allowed to be updated directly in the Options dialog
 | // options allowed to be updated directly in the Options dialog
 | ||||||
| @ -136,7 +136,7 @@ function isAllowed(name: string) { | |||||||
|         || name.startsWith("hideArchivedNotes"); |         || name.startsWith("hideArchivedNotes"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getOptions, |     getOptions, | ||||||
|     updateOption, |     updateOption, | ||||||
|     updateOptions, |     updateOptions, | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import { Request } from "express"; | import { Request } from "express"; | ||||||
| 
 | 
 | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import markdownService = require('../../services/import/markdown'); | import markdownService from "../../services/import/markdown.js"; | ||||||
| 
 | 
 | ||||||
| function getIconUsage() { | function getIconUsage() { | ||||||
|     const iconClassToCountMap: Record<string, number> = {}; |     const iconClassToCountMap: Record<string, number> = {}; | ||||||
| @ -35,7 +35,7 @@ function renderMarkdown(req: Request) { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getIconUsage, |     getIconUsage, | ||||||
|     renderMarkdown |     renderMarkdown | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import passwordService = require('../../services/encryption/password'); | import passwordService from "../../services/encryption/password.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function changePassword(req: Request) { | function changePassword(req: Request) { | ||||||
| @ -22,7 +22,7 @@ function resetPassword(req: Request) { | |||||||
|     return passwordService.resetPassword(); |     return passwordService.resetPassword(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     changePassword, |     changePassword, | ||||||
|     resetPassword |     resetPassword | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService from "../../services/protected_session.js"; | ||||||
| import noteService = require('../../services/notes'); | import noteService from "../../services/notes.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import { RevisionRow } from '../../becca/entities/rows'; | import { RevisionRow } from '../../becca/entities/rows'; | ||||||
| 
 | 
 | ||||||
| @ -111,6 +111,6 @@ function getRecentChanges(req: Request) { | |||||||
|     return recentChanges; |     return recentChanges; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getRecentChanges |     getRecentChanges | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import BRecentNote = require('../../becca/entities/brecent_note'); | import BRecentNote from "../../becca/entities/brecent_note.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils from "../../services/date_utils.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function addRecentNote(req: Request) { | function addRecentNote(req: Request) { | ||||||
| @ -19,6 +19,6 @@ function addRecentNote(req: Request) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     addRecentNote |     addRecentNote | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| 
 | 
 | ||||||
| interface ResponseData { | interface ResponseData { | ||||||
|     noteTitles: Record<string, string>; |     noteTitles: Record<string, string>; | ||||||
| @ -76,6 +76,6 @@ function getRelationMap(req: Request) { | |||||||
|     return resp; |     return resp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getRelationMap |     getRelationMap | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,17 +1,17 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import beccaService = require('../../becca/becca_service'); | import beccaService from "../../becca/becca_service.js"; | ||||||
| import revisionService = require('../../services/revisions'); | import revisionService from "../../services/revisions.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import cls = require('../../services/cls'); | import cls from "../../services/cls.js"; | ||||||
| import path = require('path'); | import path from "path"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import blobService = require('../../services/blob'); | import blobService from "../../services/blob.js"; | ||||||
| import eraseService = require("../../services/erase"); | import eraseService from "../../services/erase.js"; | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| import BRevision = require('../../becca/entities/brevision'); | import BRevision from "../../becca/entities/brevision.js"; | ||||||
| import BNote = require('../../becca/entities/bnote'); | import BNote from "../../becca/entities/bnote.js"; | ||||||
| import { NotePojo } from '../../becca/becca-interface'; | import { NotePojo } from '../../becca/becca-interface'; | ||||||
| 
 | 
 | ||||||
| interface NotePath { | interface NotePath { | ||||||
| @ -200,7 +200,7 @@ function getNotePathData(note: BNote): NotePath | undefined { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getRevisionBlob, |     getRevisionBlob, | ||||||
|     getRevisions, |     getRevisions, | ||||||
|     getRevision, |     getRevision, | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import scriptService = require('../../services/script'); | import scriptService from "../../services/script.js"; | ||||||
| import attributeService = require('../../services/attributes'); | import attributeService from "../../services/attributes.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import syncService = require('../../services/sync'); | import syncService from "../../services/sync.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| interface ScriptBody { | interface ScriptBody { | ||||||
| @ -131,7 +131,7 @@ function getBundle(req: Request) { | |||||||
|     return scriptService.getScriptBundleForFrontend(note, script, params); |     return scriptService.getScriptBundleForFrontend(note, script, params); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     exec, |     exec, | ||||||
|     run, |     run, | ||||||
|     getStartupBundles, |     getStartupBundles, | ||||||
|  | |||||||
| @ -2,21 +2,21 @@ | |||||||
| 
 | 
 | ||||||
| import { Request } from "express"; | import { Request } from "express"; | ||||||
| 
 | 
 | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import SearchContext = require('../../services/search/search_context'); | import SearchContext from "../../services/search/search_context.js"; | ||||||
| import searchService = require('../../services/search/services/search'); | import searchService, { EMPTY_RESULT, SearchNoteResult } from "../../services/search/services/search.js"; | ||||||
| import bulkActionService = require('../../services/bulk_actions'); | import bulkActionService from "../../services/bulk_actions.js"; | ||||||
| import cls = require('../../services/cls'); | import cls from "../../services/cls.js"; | ||||||
| import attributeFormatter = require('../../services/attribute_formatter'); | import attributeFormatter from "../../services/attribute_formatter.js"; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import SearchResult = require("../../services/search/search_result"); | import SearchResult from "../../services/search/search_result.js"; | ||||||
| 
 | 
 | ||||||
| function searchFromNote(req: Request) { | function searchFromNote(req: Request): SearchNoteResult { | ||||||
|     const note = becca.getNoteOrThrow(req.params.noteId); |     const note = becca.getNoteOrThrow(req.params.noteId); | ||||||
| 
 | 
 | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         // this can be triggered from recent changes, and it's harmless to return an empty list rather than fail
 |         // this can be triggered from recent changes, and it's harmless to return an empty list rather than fail
 | ||||||
|         return []; |         return EMPTY_RESULT; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (note.type !== 'search') { |     if (note.type !== 'search') { | ||||||
| @ -126,7 +126,7 @@ function searchTemplates() { | |||||||
|     }).map(note => note.noteId); |     }).map(note => note.noteId); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     searchFromNote, |     searchFromNote, | ||||||
|     searchAndExecute, |     searchAndExecute, | ||||||
|     getRelatedNotes, |     getRelatedNotes, | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import imageType = require('image-type'); | import imageType from "image-type"; | ||||||
| import imageService = require('../../services/image'); | import imageService from "../../services/image.js"; | ||||||
| import noteService = require('../../services/notes'); | import noteService from "../../services/notes.js"; | ||||||
| import sanitize_attribute_name = require('../../services/sanitize_attribute_name'); | import sanitize_attribute_name from "../../services/sanitize_attribute_name.js"; | ||||||
| import specialNotesService = require('../../services/special_notes'); | import specialNotesService from "../../services/special_notes.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import { AppRequest } from '../route-interface'; | import { AppRequest } from '../route-interface'; | ||||||
| 
 | 
 | ||||||
| @ -84,7 +84,7 @@ function saveNote(req: Request) { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     uploadImage, |     uploadImage, | ||||||
|     saveNote |     saveNote | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sqlInit = require('../../services/sql_init'); | import sqlInit from "../../services/sql_init.js"; | ||||||
| import setupService = require('../../services/setup'); | import setupService from "../../services/setup.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import appInfo = require('../../services/app_info'); | import appInfo from "../../services/app_info.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function getStatus() { | function getStatus() { | ||||||
| @ -51,7 +51,7 @@ function getSyncSeed() { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getStatus, |     getStatus, | ||||||
|     setupNewDocument, |     setupNewDocument, | ||||||
|     setupSyncFromServer, |     setupSyncFromServer, | ||||||
|  | |||||||
| @ -2,8 +2,8 @@ | |||||||
| 
 | 
 | ||||||
| import { Request } from "express"; | import { Request } from "express"; | ||||||
| 
 | 
 | ||||||
| import similarityService = require('../../becca/similarity'); | import similarityService from "../../becca/similarity.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| 
 | 
 | ||||||
| async function getSimilarNotes(req: Request) { | async function getSimilarNotes(req: Request) { | ||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
| @ -13,6 +13,6 @@ async function getSimilarNotes(req: Request) { | |||||||
|     return await similarityService.findSimilarNotes(noteId); |     return await similarityService.findSimilarNotes(noteId); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getSimilarNotes |     getSimilarNotes | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import dateNoteService = require('../../services/date_notes'); | import dateNoteService from "../../services/date_notes.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import cls = require('../../services/cls'); | import cls from "../../services/cls.js"; | ||||||
| import specialNotesService = require('../../services/special_notes'); | import specialNotesService from "../../services/special_notes.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function getInboxNote(req: Request) { | function getInboxNote(req: Request) { | ||||||
| @ -82,7 +82,7 @@ function createOrUpdateScriptLauncherFromApi(req: Request) { | |||||||
|     return specialNotesService.createOrUpdateScriptLauncherFromApi(req.body); |     return specialNotesService.createOrUpdateScriptLauncherFromApi(req.body); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getInboxNote, |     getInboxNote, | ||||||
|     getDayNote, |     getDayNote, | ||||||
|     getWeekNote, |     getWeekNote, | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
| 
 | 
 | ||||||
| function getSchema() { | function getSchema() { | ||||||
|     const tableNames = sql.getColumn(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`); |     const tableNames = sql.getColumn(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`); | ||||||
| @ -66,7 +66,7 @@ function execute(req: Request) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getSchema, |     getSchema, | ||||||
|     execute |     execute | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| function getNoteSize(req: Request) { | function getNoteSize(req: Request) { | ||||||
| @ -45,7 +45,7 @@ function getSubtreeSize(req: Request) { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getNoteSize, |     getNoteSize, | ||||||
|     getSubtreeSize |     getSubtreeSize | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,19 +1,20 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import syncService = require('../../services/sync'); | import syncService from "../../services/sync.js"; | ||||||
| import syncUpdateService = require('../../services/sync_update'); | import syncUpdateService from "../../services/sync_update.js"; | ||||||
| import entityChangesService = require('../../services/entity_changes'); | import entityChangesService from "../../services/entity_changes.js"; | ||||||
| import sql = require('../../services/sql'); | import sql from "../../services/sql.js"; | ||||||
| import sqlInit = require('../../services/sql_init'); | import sqlInit from "../../services/sql_init.js"; | ||||||
| import optionService = require('../../services/options'); | import optionService from "../../services/options.js"; | ||||||
| import contentHashService = require('../../services/content_hash'); | import contentHashService from "../../services/content_hash.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import syncOptions = require('../../services/sync_options'); | import syncOptions from "../../services/sync_options.js"; | ||||||
| import utils = require('../../services/utils'); | import utils from "../../services/utils.js"; | ||||||
| import ws = require('../../services/ws'); | import ws from "../../services/ws.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import { EntityChange, EntityChangeRecord } from '../../services/entity_changes_interface'; | import { EntityChange, EntityChangeRecord } from '../../services/entity_changes_interface'; | ||||||
| import ValidationError = require('../../errors/validation_error'); | import ValidationError from "../../errors/validation_error.js"; | ||||||
|  | import consistencyChecksService from "../../services/consistency_checks.js"; | ||||||
| 
 | 
 | ||||||
| async function testSync() { | async function testSync() { | ||||||
|     try { |     try { | ||||||
| @ -206,10 +207,10 @@ function queueSector(req: Request) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function checkEntityChanges() { | function checkEntityChanges() { | ||||||
|     require('../../services/consistency_checks').runEntityChangesChecks(); |     consistencyChecksService.runEntityChangesChecks(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     testSync, |     testSync, | ||||||
|     checkSync, |     checkSync, | ||||||
|     syncNow, |     syncNow, | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import becca = require('../../becca/becca'); | import becca from "../../becca/becca.js"; | ||||||
| import log = require('../../services/log'); | import log from "../../services/log.js"; | ||||||
| import NotFoundError = require('../../errors/not_found_error'); | import NotFoundError from "../../errors/not_found_error.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| import BNote = require('../../becca/entities/bnote'); | import BNote from "../../becca/entities/bnote.js"; | ||||||
| 
 | 
 | ||||||
| function getNotesAndBranchesAndAttributes(_noteIds: string[] | Set<string>) { | function getNotesAndBranchesAndAttributes(_noteIds: string[] | Set<string>) { | ||||||
|     const noteIds = new Set(_noteIds); |     const noteIds = new Set(_noteIds); | ||||||
| @ -160,7 +160,7 @@ function load(req: Request) { | |||||||
|     return getNotesAndBranchesAndAttributes(req.body.noteIds); |     return getNotesAndBranchesAndAttributes(req.body.noteIds); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getTree, |     getTree, | ||||||
|     load |     load | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| import assetPath = require('../services/asset_path'); | import assetPath from "../services/asset_path.js"; | ||||||
| import path = require("path"); | import path from "path"; | ||||||
| import express = require("express"); | import express from "express"; | ||||||
| import env = require('../services/env'); | import env from "../services/env.js"; | ||||||
| import serveStatic = require('serve-static'); | import serveStatic from "serve-static"; | ||||||
| 
 | 
 | ||||||
| const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => { | const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => { | ||||||
|     if (!env.isDev()) { |     if (!env.isDev()) { | ||||||
| @ -76,6 +76,6 @@ function register(app: express.Application) { | |||||||
|     app.use(`/${assetPath}/translations/`, persistentCacheStatic(path.join(srcRoot, "public", "translations/"))); |     app.use(`/${assetPath}/translations/`, persistentCacheStatic(path.join(srcRoot, "public", "translations/"))); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| import fileService = require('./api/files'); | import fileService from "./api/files.js"; | ||||||
| import scriptService = require('../services/script'); | import scriptService from "../services/script.js"; | ||||||
| import cls = require('../services/cls'); | import cls from "../services/cls.js"; | ||||||
| import sql = require('../services/sql'); | import sql from "../services/sql.js"; | ||||||
| import becca = require('../becca/becca'); | import becca from "../becca/becca.js"; | ||||||
| import { Request, Response, Router } from 'express'; | import { Request, Response, Router } from 'express'; | ||||||
| 
 | 
 | ||||||
| function handleRequest(req: Request, res: Response) { | function handleRequest(req: Request, res: Response) { | ||||||
| @ -84,6 +84,6 @@ function register(router: Router) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -56,4 +56,4 @@ function init(app: Application) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = init; | export default init; | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import { Application, NextFunction, Request, Response } from 'express'; | import { Application, NextFunction, Request, Response } from 'express'; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| 
 | 
 | ||||||
| function register(app: Application) { | function register(app: Application) { | ||||||
|     app.use((err: any, req: Request, res: Response, next: NextFunction) => { |     app.use((err: any, req: Request, res: Response, next: NextFunction) => { | ||||||
| @ -39,6 +39,6 @@ function register(app: Application) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,16 +1,16 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sql = require('../services/sql'); | import sql from "../services/sql.js"; | ||||||
| import attributeService = require('../services/attributes'); | import attributeService from "../services/attributes.js"; | ||||||
| import config = require('../services/config'); | import config from "../services/config.js"; | ||||||
| import optionService = require('../services/options'); | import optionService from "../services/options.js"; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| import env = require('../services/env'); | import env from "../services/env.js"; | ||||||
| import utils = require('../services/utils'); | import utils from "../services/utils.js"; | ||||||
| import protectedSessionService = require('../services/protected_session'); | import protectedSessionService from "../services/protected_session.js"; | ||||||
| import packageJson = require('../../package.json'); | import packageJson from "../../package.json"; | ||||||
| import assetPath = require('../services/asset_path'); | import assetPath from "../services/asset_path.js"; | ||||||
| import appPath = require('../services/app_path'); | import appPath from "../services/app_path.js"; | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| 
 | 
 | ||||||
| function index(req: Request, res: Response) { | function index(req: Request, res: Response) { | ||||||
| @ -64,6 +64,6 @@ function getAppCssNoteIds() { | |||||||
|     return attributeService.getNotesWithLabel('appCss').map(note => note.noteId); |     return attributeService.getNotesWithLabel('appCss').map(note => note.noteId); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     index |     index | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,13 +1,13 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import utils = require('../services/utils'); | import utils from "../services/utils.js"; | ||||||
| import optionService = require('../services/options'); | import optionService from "../services/options.js"; | ||||||
| import myScryptService = require('../services/encryption/my_scrypt'); | import myScryptService from "../services/encryption/my_scrypt.js"; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| import passwordService = require('../services/encryption/password'); | import passwordService from "../services/encryption/password.js"; | ||||||
| import assetPath = require('../services/asset_path'); | import assetPath from "../services/asset_path.js"; | ||||||
| import appPath = require('../services/app_path'); | import appPath from "../services/app_path.js"; | ||||||
| import ValidationError = require('../errors/validation_error'); | import ValidationError from "../errors/validation_error.js"; | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| import { AppRequest } from './route-interface'; | import { AppRequest } from './route-interface'; | ||||||
| 
 | 
 | ||||||
| @ -102,7 +102,7 @@ function logout(req: AppRequest, res: Response) { | |||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     loginPage, |     loginPage, | ||||||
|     setPasswordPage, |     setPasswordPage, | ||||||
|     setPassword, |     setPassword, | ||||||
|  | |||||||
| @ -1,75 +1,75 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import utils = require('../services/utils'); | import utils from "../services/utils.js"; | ||||||
| import multer = require('multer'); | import multer from "multer"; | ||||||
| import log = require('../services/log'); | import log from "../services/log.js"; | ||||||
| import express = require('express'); | import express from "express"; | ||||||
| const router = express.Router(); | const router = express.Router(); | ||||||
| import auth = require('../services/auth'); | import auth from "../services/auth.js"; | ||||||
| import cls = require('../services/cls'); | import cls from "../services/cls.js"; | ||||||
| import sql = require('../services/sql'); | import sql from "../services/sql.js"; | ||||||
| import entityChangesService = require('../services/entity_changes'); | import entityChangesService from "../services/entity_changes.js"; | ||||||
| import csurf = require('csurf'); | import csurf from "csurf"; | ||||||
| import { createPartialContentHandler } from "express-partial-content"; | import { createPartialContentHandler } from "express-partial-content"; | ||||||
| import rateLimit = require("express-rate-limit"); | import rateLimit from "express-rate-limit"; | ||||||
| import AbstractBeccaEntity = require('../becca/entities/abstract_becca_entity'); | import AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js"; | ||||||
| import NotFoundError = require('../errors/not_found_error'); | import NotFoundError from "../errors/not_found_error.js"; | ||||||
| import ValidationError = require('../errors/validation_error'); | import ValidationError from "../errors/validation_error.js"; | ||||||
| 
 | 
 | ||||||
| // page routes
 | // page routes
 | ||||||
| import setupRoute = require('./setup'); | import setupRoute from "./setup.js"; | ||||||
| import loginRoute = require('./login'); | import loginRoute from "./login.js"; | ||||||
| import indexRoute = require('./index'); | import indexRoute from "./index.js"; | ||||||
| 
 | 
 | ||||||
| // API routes
 | // API routes
 | ||||||
| import treeApiRoute = require('./api/tree'); | import treeApiRoute from "./api/tree.js"; | ||||||
| import notesApiRoute = require('./api/notes'); | import notesApiRoute from "./api/notes.js"; | ||||||
| import branchesApiRoute = require('./api/branches'); | import branchesApiRoute from "./api/branches.js"; | ||||||
| import attachmentsApiRoute = require('./api/attachments'); | import attachmentsApiRoute from "./api/attachments.js"; | ||||||
| import autocompleteApiRoute = require('./api/autocomplete'); | import autocompleteApiRoute from "./api/autocomplete.js"; | ||||||
| import cloningApiRoute = require('./api/cloning'); | import cloningApiRoute from "./api/cloning.js"; | ||||||
| import revisionsApiRoute = require('./api/revisions'); | import revisionsApiRoute from "./api/revisions.js"; | ||||||
| import recentChangesApiRoute = require('./api/recent_changes'); | import recentChangesApiRoute from "./api/recent_changes.js"; | ||||||
| import optionsApiRoute = require('./api/options'); | import optionsApiRoute from "./api/options.js"; | ||||||
| import passwordApiRoute = require('./api/password'); | import passwordApiRoute from "./api/password.js"; | ||||||
| import syncApiRoute = require('./api/sync'); | import syncApiRoute from "./api/sync.js"; | ||||||
| import loginApiRoute = require('./api/login'); | import loginApiRoute from "./api/login.js"; | ||||||
| import recentNotesRoute = require('./api/recent_notes'); | import recentNotesRoute from "./api/recent_notes.js"; | ||||||
| import appInfoRoute = require('./api/app_info'); | import appInfoRoute from "./api/app_info.js"; | ||||||
| import exportRoute = require('./api/export'); | import exportRoute from "./api/export.js"; | ||||||
| import importRoute = require('./api/import'); | import importRoute from "./api/import.js"; | ||||||
| import setupApiRoute = require('./api/setup'); | import setupApiRoute from "./api/setup.js"; | ||||||
| import sqlRoute = require('./api/sql'); | import sqlRoute from "./api/sql.js"; | ||||||
| import databaseRoute = require('./api/database'); | import databaseRoute from "./api/database.js"; | ||||||
| import imageRoute = require('./api/image'); | import imageRoute from "./api/image.js"; | ||||||
| import attributesRoute = require('./api/attributes'); | import attributesRoute from "./api/attributes.js"; | ||||||
| import scriptRoute = require('./api/script'); | import scriptRoute from "./api/script.js"; | ||||||
| import senderRoute = require('./api/sender'); | import senderRoute from "./api/sender.js"; | ||||||
| import filesRoute = require('./api/files'); | import filesRoute from "./api/files.js"; | ||||||
| import searchRoute = require('./api/search'); | import searchRoute from "./api/search.js"; | ||||||
| import bulkActionRoute = require('./api/bulk_action'); | import bulkActionRoute from "./api/bulk_action.js"; | ||||||
| import specialNotesRoute = require('./api/special_notes'); | import specialNotesRoute from "./api/special_notes.js"; | ||||||
| import noteMapRoute = require('./api/note_map'); | import noteMapRoute from "./api/note_map.js"; | ||||||
| import clipperRoute = require('./api/clipper'); | import clipperRoute from "./api/clipper.js"; | ||||||
| import similarNotesRoute = require('./api/similar_notes'); | import similarNotesRoute from "./api/similar_notes.js"; | ||||||
| import keysRoute = require('./api/keys'); | import keysRoute from "./api/keys.js"; | ||||||
| import backendLogRoute = require('./api/backend_log'); | import backendLogRoute from "./api/backend_log.js"; | ||||||
| import statsRoute = require('./api/stats'); | import statsRoute from "./api/stats.js"; | ||||||
| import fontsRoute = require('./api/fonts'); | import fontsRoute from "./api/fonts.js"; | ||||||
| import etapiTokensApiRoutes = require('./api/etapi_tokens'); | import etapiTokensApiRoutes from "./api/etapi_tokens.js"; | ||||||
| import relationMapApiRoute = require('./api/relation-map'); | import relationMapApiRoute from "./api/relation-map.js"; | ||||||
| import otherRoute = require('./api/other'); | import otherRoute from "./api/other.js"; | ||||||
| import shareRoutes = require('../share/routes'); | import shareRoutes from "../share/routes.js"; | ||||||
| 
 | 
 | ||||||
| import etapiAuthRoutes = require('../etapi/auth'); | import etapiAuthRoutes from "../etapi/auth.js"; | ||||||
| import etapiAppInfoRoutes = require('../etapi/app_info'); | import etapiAppInfoRoutes from "../etapi/app_info.js"; | ||||||
| import etapiAttachmentRoutes = require('../etapi/attachments'); | import etapiAttachmentRoutes from "../etapi/attachments.js"; | ||||||
| import etapiAttributeRoutes = require('../etapi/attributes'); | import etapiAttributeRoutes from "../etapi/attributes.js"; | ||||||
| import etapiBranchRoutes = require('../etapi/branches'); | import etapiBranchRoutes from "../etapi/branches.js"; | ||||||
| import etapiNoteRoutes = require('../etapi/notes'); | import etapiNoteRoutes from "../etapi/notes.js"; | ||||||
| import etapiSpecialNoteRoutes = require('../etapi/special_notes'); | import etapiSpecialNoteRoutes from "../etapi/special_notes.js"; | ||||||
| import etapiSpecRoute = require('../etapi/spec'); | import etapiSpecRoute from "../etapi/spec.js"; | ||||||
| import etapiBackupRoute = require('../etapi/backup'); | import etapiBackupRoute from "../etapi/backup.js"; | ||||||
| import { AppRequest, AppRequestHandler } from './route-interface'; | import { AppRequest, AppRequestHandler } from './route-interface'; | ||||||
| 
 | 
 | ||||||
| const csrfMiddleware = csurf({ | const csrfMiddleware = csurf({ | ||||||
| @ -106,7 +106,7 @@ function register(app: express.Application) { | |||||||
|     route(GET, '/login', [auth.checkAppInitialized, auth.checkPasswordSet], loginRoute.loginPage); |     route(GET, '/login', [auth.checkAppInitialized, auth.checkPasswordSet], loginRoute.loginPage); | ||||||
|     route(GET, '/set-password', [auth.checkAppInitialized, auth.checkPasswordNotSet], loginRoute.setPasswordPage); |     route(GET, '/set-password', [auth.checkAppInitialized, auth.checkPasswordNotSet], loginRoute.setPasswordPage); | ||||||
| 
 | 
 | ||||||
|     const loginRateLimiter = rateLimit.rateLimit({ |     const loginRateLimiter = rateLimit({ | ||||||
|         windowMs: 15 * 60 * 1000, // 15 minutes
 |         windowMs: 15 * 60 * 1000, // 15 minutes
 | ||||||
|         max: 10, // limit each IP to 10 requests per windowMs
 |         max: 10, // limit each IP to 10 requests per windowMs
 | ||||||
|         skipSuccessfulRequests: true // successful auth to rate-limited ETAPI routes isn't counted. However, successful auth to /login is still counted!
 |         skipSuccessfulRequests: true // successful auth to rate-limited ETAPI routes isn't counted. However, successful auth to /login is still counted!
 | ||||||
| @ -517,6 +517,6 @@ function createUploadMiddleware() { | |||||||
|     return multer(multerOptions).single('upload'); |     return multer(multerOptions).single('upload'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     register |     register | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,7 +1,8 @@ | |||||||
| import session = require("express-session"); | import session from "express-session"; | ||||||
| import sessionSecret = require('../services/session_secret'); | import sessionFileStore from "session-file-store"; | ||||||
| import dataDir = require('../services/data_dir'); | import sessionSecret from "../services/session_secret.js"; | ||||||
| const FileStore = require('session-file-store')(session); | import dataDir from "../services/data_dir.js"; | ||||||
|  | const FileStore = sessionFileStore(session); | ||||||
| 
 | 
 | ||||||
| const sessionParser = session({ | const sessionParser = session({ | ||||||
|     secret: sessionSecret, |     secret: sessionSecret, | ||||||
| @ -19,4 +20,4 @@ const sessionParser = session({ | |||||||
|     }) |     }) | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| export = sessionParser; | export default sessionParser; | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import sqlInit = require('../services/sql_init'); | import sqlInit from "../services/sql_init.js"; | ||||||
| import setupService = require('../services/setup'); | import setupService from "../services/setup.js"; | ||||||
| import utils = require('../services/utils'); | import utils from "../services/utils.js"; | ||||||
| import assetPath = require('../services/asset_path'); | import assetPath from "../services/asset_path.js"; | ||||||
| import appPath = require('../services/app_path'); | import appPath from "../services/app_path.js"; | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| 
 | 
 | ||||||
| function setupPage(req: Request, res: Response) { | function setupPage(req: Request, res: Response) { | ||||||
| @ -38,6 +38,6 @@ function setupPage(req: Request, res: Response) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     setupPage |     setupPage | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| import BUILTIN_ATTRIBUTES = require('./builtin_attributes'); | import BUILTIN_ATTRIBUTES from "./builtin_attributes.js"; | ||||||
| import fs = require("fs-extra"); | import fs from "fs-extra"; | ||||||
| import dataDir = require('./data_dir'); | import dataDir from "./data_dir.js"; | ||||||
| import dateUtils = require('./date_utils'); | import dateUtils from "./date_utils.js"; | ||||||
| import Database = require("better-sqlite3"); | import Database from "better-sqlite3"; | ||||||
| import sql = require('./sql'); | import sql from "./sql.js"; | ||||||
| import path = require("path"); | import path from "path"; | ||||||
| 
 | 
 | ||||||
| function getFullAnonymizationScript() { | function getFullAnonymizationScript() { | ||||||
|     // we want to delete all non-builtin attributes because they can contain sensitive names and values
 |     // we want to delete all non-builtin attributes because they can contain sensitive names and values
 | ||||||
| @ -90,7 +90,7 @@ function getExistingAnonymizedDatabases() { | |||||||
|         })); |         })); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     getFullAnonymizationScript, |     getFullAnonymizationScript, | ||||||
|     createAnonymizedCopy, |     createAnonymizedCopy, | ||||||
|     getExistingAnonymizedDatabases |     getExistingAnonymizedDatabases | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import path = require('path'); | import path from "path"; | ||||||
| import resourceDir = require('./resource_dir'); | import resourceDir from "./resource_dir.js"; | ||||||
| import log = require('./log'); | import log from "./log.js"; | ||||||
| import os = require('os'); | import os from "os"; | ||||||
| import fs = require('fs'); | import fs from "fs"; | ||||||
| import config = require('./config'); | import config from "./config.js"; | ||||||
| import utils = require('./utils'); | import utils from "./utils.js"; | ||||||
| 
 | 
 | ||||||
| const template = `[Desktop Entry]
 | const template = `[Desktop Entry]
 | ||||||
| Type=Application | Type=Application | ||||||
| @ -68,6 +68,6 @@ function getExePath() { | |||||||
|      return path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, 'trilium'); |      return path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, 'trilium'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     installLocalAppIcon |     installLocalAppIcon | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,14 +1,14 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import build = require('./build'); | import build from "./build.js"; | ||||||
| import packageJson = require('../../package.json'); | import packageJson from "../../package.json"; | ||||||
| import dataDir = require('./data_dir'); | import dataDir from "./data_dir.js"; | ||||||
| 
 | 
 | ||||||
| const APP_DB_VERSION = 228; | const APP_DB_VERSION = 228; | ||||||
| const SYNC_VERSION = 32; | const SYNC_VERSION = 32; | ||||||
| const CLIPPER_PROTOCOL_VERSION = "1.0"; | const CLIPPER_PROTOCOL_VERSION = "1.0"; | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     appVersion: packageJson.version, |     appVersion: packageJson.version, | ||||||
|     dbVersion: APP_DB_VERSION, |     dbVersion: APP_DB_VERSION, | ||||||
|     nodeVersion: process.version, |     nodeVersion: process.version, | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| import assetPath = require('./asset_path'); | import assetPath from "./asset_path.js"; | ||||||
| import env = require('./env'); | import env from "./env.js"; | ||||||
| 
 | 
 | ||||||
| export = env.isDev() | export default env.isDev() | ||||||
|     ? assetPath + "/app" |     ? assetPath + "/app" | ||||||
|     : assetPath + "/app-dist"; |     : assetPath + "/app-dist"; | ||||||
|  | |||||||
| @ -1,3 +1,3 @@ | |||||||
| import packageJson = require('../../package.json'); | import packageJson from "../../package.json"; | ||||||
| 
 | 
 | ||||||
| export = `assets/v${packageJson.version}`; | export default `assets/v${packageJson.version}`; | ||||||
|  | |||||||
| @ -47,6 +47,6 @@ function formatValue(val: string) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export = { | export default { | ||||||
|     formatAttrForSearch |     formatAttrForSearch | ||||||
| }; | }; | ||||||
|  | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran