From 127486fdf57a0e15e2db87541f5c4a3c580742ac Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 15 Feb 2023 23:45:25 +0100 Subject: [PATCH] removed deprecated API methods --- package-lock.json | 29 +++---- package.json | 4 +- .../app/services/frontend_script_api.js | 81 ------------------- src/services/backend_script_api.js | 38 +-------- 4 files changed, 21 insertions(+), 131 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76ad5d4f6..ed191db2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "trilium", "version": "0.58.7", "hasInstallScript": true, "license": "AGPL-3.0-only", @@ -14,7 +15,7 @@ "@excalidraw/excalidraw": "0.14.2", "archiver": "5.3.1", "async-mutex": "0.4.0", - "axios": "1.3.2", + "axios": "1.3.3", "better-sqlite3": "8.1.0", "canvas": "2.11.0", "chokidar": "3.5.3", @@ -71,7 +72,7 @@ "tmp": "0.2.1", "turndown": "7.1.1", "unescape": "1.0.1", - "ws": "8.12.0", + "ws": "8.12.1", "xml2js": "0.4.23", "yauzl": "2.10.0" }, @@ -1928,9 +1929,9 @@ "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, "node_modules/axios": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.2.tgz", - "integrity": "sha512-1M3O703bYqYuPhbHeya5bnhpYVsDDRyQSabNja04mZtboLNSuZ4YrltestrLXfHgmzua4TpUqRiVKbiQuo2epw==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.3.tgz", + "integrity": "sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA==", "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -10183,9 +10184,9 @@ } }, "node_modules/ws": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz", - "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", "engines": { "node": ">=10.0.0" }, @@ -11849,9 +11850,9 @@ "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, "axios": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.2.tgz", - "integrity": "sha512-1M3O703bYqYuPhbHeya5bnhpYVsDDRyQSabNja04mZtboLNSuZ4YrltestrLXfHgmzua4TpUqRiVKbiQuo2epw==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.3.tgz", + "integrity": "sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA==", "requires": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -18178,9 +18179,9 @@ } }, "ws": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz", - "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", "requires": {} }, "xhr": { diff --git a/package.json b/package.json index 0a2292a4d..91a4133ec 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@excalidraw/excalidraw": "0.14.2", "archiver": "5.3.1", "async-mutex": "0.4.0", - "axios": "1.3.2", + "axios": "1.3.3", "better-sqlite3": "8.1.0", "canvas": "2.11.0", "chokidar": "3.5.3", @@ -89,7 +89,7 @@ "tmp": "0.2.1", "turndown": "7.1.1", "unescape": "1.0.1", - "ws": "8.12.0", + "ws": "8.12.1", "xml2js": "0.4.23", "yauzl": "2.10.0" }, diff --git a/src/public/app/services/frontend_script_api.js b/src/public/app/services/frontend_script_api.js index 7734abd0f..418a28295 100644 --- a/src/public/app/services/frontend_script_api.js +++ b/src/public/app/services/frontend_script_api.js @@ -202,12 +202,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain } }; - /** - * @deprecated new name of this API call is runOnBackend so use that - * @method - */ - this.runOnServer = this.runOnBackend; - /** * This is a powerful search method - you can search by attributes and their values, e.g.: * "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search @@ -321,12 +315,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ this.triggerEvent = (name, data) => appContext.triggerEvent(name, data); - /** - * @method - * @deprecated this is now no-op since all the changes should be gracefully handled per widget - */ - this.refreshTree = () => {}; - /** * Create note link (jQuery object) for given note. * @@ -340,19 +328,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ this.createNoteLink = linkService.createNoteLink; - /** - * Adds given text to the editor cursor - * - * @method - * @deprecated use addTextToActiveContextEditor() instead - * @param {string} text - this must be clear text, HTML is not supported. - */ - this.addTextToActiveTabEditor = text => { - console.warn("api.addTextToActiveTabEditor() is deprecated, use addTextToActiveContextEditor() instead."); - - return appContext.triggerCommand('addTextToActiveEditor', {text}); - }; - /** * Adds given text to the editor cursor * @@ -361,36 +336,12 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ this.addTextToActiveContextEditor = text => appContext.triggerCommand('addTextToActiveEditor', {text}); - /** - * @method - * @deprecated use getActiveContextNote() instead - * @returns {FNote} active note (loaded into right pane) - */ - this.getActiveTabNote = () => { - console.warn("api.getActiveTabNote() is deprecated, use getActiveContextNote() instead."); - - return appContext.tabManager.getActiveContextNote(); - }; - /** * @method * @returns {FNote} active note (loaded into right pane) */ this.getActiveContextNote = () => appContext.tabManager.getActiveContextNote(); - /** - * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance. - * - * @method - * @deprecated use getActiveContextTextEditor() - * @param [callback] - callback receiving "textEditor" instance - */ - this.getActiveTabTextEditor = callback => { - console.warn("api.getActiveTabTextEditor() is deprecated, use getActiveContextTextEditor() instead."); - - return appContext.tabManager.getActiveContext()?.getTextEditor(callback); - }; - /** * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance. * @@ -416,17 +367,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ this.getActiveNoteDetailWidget = () => new Promise(resolve => appContext.triggerCommand('executeInActiveNoteDetailWidget', {callback: resolve})); - /** - * @method - * @deprecated use getActiveContextNotePath() instead - * @returns {Promise} returns note path of active note or null if there isn't active note - */ - this.getActiveTabNotePath = () => { - console.warn("api.getActiveTabNotePath() is deprecated, use getActiveContextNotePath() instead."); - - return appContext.tabManager.getActiveContextNotePath(); - }; - /** * @method * @returns {Promise} returns note path of active note or null if there isn't active note @@ -449,17 +389,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ this.setupElementTooltip = noteTooltipService.setupElementTooltip; - /** - * @method - * @deprecated use protectNote and protectSubtree instead - * @returns {Promise} - */ - this.protectActiveNote = async () => { - const activeNote = appContext.tabManager.getActiveContextNote(); - - await protectedSessionService.protectNote(activeNote.noteId, true, false); - }; - /** * @method * @param {string} noteId @@ -488,16 +417,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain */ this.getTodayNote = dateNotesService.getTodayNote; - /** - * Returns day note for a given date. If it doesn't exist, it is automatically created. - * - * @method - * @param {string} date - e.g. "2019-04-29" - * @returns {Promise} - * @deprecated use getDayNote instead - */ - this.getDateNote = dateNotesService.getDayNote; - /** * Returns day note for a given date. If it doesn't exist, it is automatically created. * diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js index 870492265..50bab0c0d 100644 --- a/src/services/backend_script_api.js +++ b/src/services/backend_script_api.js @@ -38,18 +38,16 @@ function BackendScriptApi(currentNote, apiParams) { this[key] = apiParams[key]; } - /** @property {axios} Axios library for HTTP requests. See {@link https://axios-http.com} for documentation */ + /** + * @property {axios} Axios library for HTTP requests. See {@link https://axios-http.com} for documentation + * @deprecated use native (browser compatible) fetch() instead + */ this.axios = axios; /** @property {dayjs} day.js library for date manipulation. See {@link https://day.js.org} for documentation */ this.dayjs = dayjs; /** @property {axios} xml2js library for XML parsing. See {@link https://github.com/Leonidas-from-XIV/node-xml2js} for documentation */ this.xml2js = xml2js; - // DEPRECATED - use direct api.unescapeHtml - this.utils = { - unescapeHtml: utils.unescapeHtml - }; - /** * Instance name identifies particular Trilium instance. It can be useful for scripts * if some action needs to happen on only one specific instance. @@ -315,17 +313,6 @@ function BackendScriptApi(currentNote, apiParams) { */ this.getRootCalendarNote = dateNoteService.getRootCalendarNote; - /** - * Returns day note for given date. If such note doesn't exist, it is created. - * - * @method - * @param {string} date in YYYY-MM-DD format - * @param {BNote} [rootNote] - specify calendar root note, normally leave empty to use the default calendar - * @returns {BNote|null} - * @deprecated use getDayNote instead - */ - this.getDateNote = dateNoteService.getDayNote; - /** * Returns day note for given date. If such note doesn't exist, it is created. * @@ -377,14 +364,6 @@ function BackendScriptApi(currentNote, apiParams) { */ this.getYearNote = dateNoteService.getYearNote; - /** - * @method - * @deprecated use sortNotes instead - * @param {string} parentNoteId - this note's child notes will be sorted - * @returns {void} - */ - this.sortNotesByTitle = parentNoteId => treeService.sortNotes(parentNoteId); - /** * Sort child notes of a given note. * @@ -457,15 +436,6 @@ function BackendScriptApi(currentNote, apiParams) { */ this.sql = sql; - /** - * @method - * @deprecated this is now no-op since all the changes should be gracefully handled per widget - * @returns {void} - */ - this.refreshTree = () => { - console.warn("api.refreshTree() is a NO-OP and can be removed from your script.") - }; - /** * @method * @returns {{syncVersion, appVersion, buildRevision, dbVersion, dataDirectory, buildDate}|*} - object representing basic info about running Trilium version