mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-30 20:41:33 +08:00 
			
		
		
		
	server-ts: Remove .js extensions in src/becca
This commit is contained in:
		
							parent
							
								
									3a20bef1a9
								
							
						
					
					
						commit
						2c0063a5cc
					
				| @ -155,7 +155,7 @@ class Becca { | |||||||
|     getRevision(revisionId) { |     getRevision(revisionId) { | ||||||
|         const row = sql.getRow("SELECT * FROM revisions WHERE revisionId = ?", [revisionId]); |         const row = sql.getRow("SELECT * FROM revisions WHERE revisionId = ?", [revisionId]); | ||||||
| 
 | 
 | ||||||
|         const BRevision = require('./entities/brevision.js'); // avoiding circular dependency problems
 |         const BRevision = require('./entities/brevision'); // avoiding circular dependency problems
 | ||||||
|         return row ? new BRevision(row) : null; |         return row ? new BRevision(row) : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -170,7 +170,7 @@ 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.js'); // avoiding circular dependency problems
 |         const BAttachment = require('./entities/battachment'); // avoiding circular dependency problems
 | ||||||
| 
 | 
 | ||||||
|         return sql.getRows(query, [attachmentId]) |         return sql.getRows(query, [attachmentId]) | ||||||
|             .map(row => new BAttachment(row))[0]; |             .map(row => new BAttachment(row))[0]; | ||||||
| @ -187,7 +187,7 @@ class Becca { | |||||||
| 
 | 
 | ||||||
|     /** @returns {BAttachment[]} */ |     /** @returns {BAttachment[]} */ | ||||||
|     getAttachments(attachmentIds) { |     getAttachments(attachmentIds) { | ||||||
|         const BAttachment = require('./entities/battachment.js'); // avoiding circular dependency problems
 |         const BAttachment = require('./entities/battachment'); // avoiding circular dependency problems
 | ||||||
|         return sql.getManyRows("SELECT * FROM attachments WHERE attachmentId IN (???) AND isDeleted = 0", attachmentIds) |         return sql.getManyRows("SELECT * FROM attachments WHERE attachmentId IN (???) AND isDeleted = 0", attachmentIds) | ||||||
|             .map(row => new BAttachment(row)); |             .map(row => new BAttachment(row)); | ||||||
|     } |     } | ||||||
| @ -196,7 +196,7 @@ class Becca { | |||||||
|     getBlob(entity) { |     getBlob(entity) { | ||||||
|         const row = sql.getRow("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]); |         const row = sql.getRow("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]); | ||||||
| 
 | 
 | ||||||
|         const BBlob = require('./entities/bblob.js'); // avoiding circular dependency problems
 |         const BBlob = require('./entities/bblob'); // avoiding circular dependency problems
 | ||||||
|         return row ? new BBlob(row) : null; |         return row ? new BBlob(row) : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -245,7 +245,7 @@ class Becca { | |||||||
|     getRecentNotesFromQuery(query, params = []) { |     getRecentNotesFromQuery(query, params = []) { | ||||||
|         const rows = sql.getRows(query, params); |         const rows = sql.getRows(query, params); | ||||||
| 
 | 
 | ||||||
|         const BRecentNote = require('./entities/brecent_note.js'); // avoiding circular dependency problems
 |         const BRecentNote = require('./entities/brecent_note'); // avoiding circular dependency problems
 | ||||||
|         return rows.map(row => new BRecentNote(row)); |         return rows.map(row => new BRecentNote(row)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -253,7 +253,7 @@ class Becca { | |||||||
|     getRevisionsFromQuery(query, params = []) { |     getRevisionsFromQuery(query, params = []) { | ||||||
|         const rows = sql.getRows(query, params); |         const rows = sql.getRows(query, params); | ||||||
| 
 | 
 | ||||||
|         const BRevision = require('./entities/brevision.js'); // avoiding circular dependency problems
 |         const BRevision = require('./entities/brevision'); // avoiding circular dependency problems
 | ||||||
|         return rows.map(row => new BRevision(row)); |         return rows.map(row => new BRevision(row)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,23 +2,23 @@ | |||||||
| 
 | 
 | ||||||
| const sql = require('../services/sql'); | const sql = require('../services/sql'); | ||||||
| const eventService = require('../services/events'); | const eventService = require('../services/events'); | ||||||
| const becca = require('./becca.js'); | const becca = require('./becca'); | ||||||
| const sqlInit = require('../services/sql_init.js'); | const sqlInit = require('../services/sql_init'); | ||||||
| const log = require('../services/log'); | const log = require('../services/log'); | ||||||
| const BNote = require('./entities/bnote.js'); | const BNote = require('./entities/bnote'); | ||||||
| const BBranch = require('./entities/bbranch.js'); | const BBranch = require('./entities/bbranch'); | ||||||
| const BAttribute = require('./entities/battribute.js'); | const BAttribute = require('./entities/battribute'); | ||||||
| const BOption = require('./entities/boption.js'); | const BOption = require('./entities/boption'); | ||||||
| const BEtapiToken = require('./entities/betapi_token.js'); | const BEtapiToken = require('./entities/betapi_token'); | ||||||
| const cls = require('../services/cls'); | const cls = require('../services/cls'); | ||||||
| const entityConstructor = require('../becca/entity_constructor.js'); | const entityConstructor = require('../becca/entity_constructor'); | ||||||
| 
 | 
 | ||||||
| const beccaLoaded = new Promise((res, rej) => { | const beccaLoaded = new Promise((res, rej) => { | ||||||
|     sqlInit.dbReady.then(() => { |     sqlInit.dbReady.then(() => { | ||||||
|         cls.init(() => { |         cls.init(() => { | ||||||
|             load(); |             load(); | ||||||
| 
 | 
 | ||||||
|             require('../services/options_init.js').initStartupOptions(); |             require('../services/options_init').initStartupOptions(); | ||||||
| 
 | 
 | ||||||
|             res(); |             res(); | ||||||
|         }); |         }); | ||||||
| @ -71,7 +71,7 @@ function load() { | |||||||
| function reload(reason) { | function reload(reason) { | ||||||
|     load(); |     load(); | ||||||
| 
 | 
 | ||||||
|     require('../services/ws.js').reloadFrontend(reason || "becca reloaded"); |     require('../services/ws').reloadFrontend(reason || "becca reloaded"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| eventService.subscribeBeccaLoader([eventService.ENTITY_CHANGE_SYNCED],  ({entityName, entityRow}) => { | eventService.subscribeBeccaLoader([eventService.ENTITY_CHANGE_SYNCED],  ({entityName, entityRow}) => { | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const becca = require('./becca.js'); | const becca = require('./becca'); | ||||||
| const cls = require('../services/cls'); | const cls = require('../services/cls'); | ||||||
| const log = require('../services/log'); | const log = require('../services/log'); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,13 +2,13 @@ | |||||||
| 
 | 
 | ||||||
| import utils = require('../../services/utils'); | import utils = require('../../services/utils'); | ||||||
| import sql = require('../../services/sql'); | import sql = require('../../services/sql'); | ||||||
| import entityChangesService = require('../../services/entity_changes.js'); | import entityChangesService = require('../../services/entity_changes'); | ||||||
| import eventService = require('../../services/events'); | import eventService = require('../../services/events'); | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import cls = require('../../services/cls'); | import cls = require('../../services/cls'); | ||||||
| import log = require('../../services/log'); | import log = require('../../services/log'); | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService = require('../../services/protected_session'); | ||||||
| import blobService = require('../../services/blob.js'); | import blobService = require('../../services/blob'); | ||||||
| import Becca = require('../becca-interface'); | import Becca = require('../becca-interface'); | ||||||
| 
 | 
 | ||||||
| let becca: Becca | null = null; | let becca: Becca | null = null; | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| 
 | 
 | ||||||
| import utils = require('../../services/utils'); | import utils = require('../../services/utils'); | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity.js'); | import AbstractBeccaEntity = require('./abstract_becca_entity'); | ||||||
| import sql = require('../../services/sql'); | import sql = require('../../services/sql'); | ||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService = require('../../services/protected_session'); | ||||||
| import log = require('../../services/log'); | import log = require('../../services/log'); | ||||||
| @ -152,7 +152,7 @@ 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.js'); |         const noteService = require('../../services/notes'); | ||||||
| 
 | 
 | ||||||
|         const { note, branch } = noteService.createNewNote({ |         const { note, branch } = noteService.createNewNote({ | ||||||
|             parentNoteId: this.ownerId, |             parentNoteId: this.ownerId, | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import BNote = require('./bnote.js'); | import BNote = require('./bnote'); | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity.js'); | import AbstractBeccaEntity = require('./abstract_becca_entity'); | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import promotedAttributeDefinitionParser = require('../../services/promoted_attribute_definition_parser'); | import promotedAttributeDefinitionParser = require('../../services/promoted_attribute_definition_parser'); | ||||||
| import sanitizeAttributeName = require('../../services/sanitize_attribute_name'); | import sanitizeAttributeName = require('../../services/sanitize_attribute_name'); | ||||||
| import { AttributeRow, AttributeType } from './rows.js'; | import { AttributeRow, AttributeType } from './rows'; | ||||||
| 
 | 
 | ||||||
| interface SavingOpts { | interface SavingOpts { | ||||||
|     skipValidation?: boolean; |     skipValidation?: boolean; | ||||||
|  | |||||||
| @ -1,13 +1,13 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import BNote = require('./bnote.js'); | import BNote = require('./bnote'); | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity.js'); | import AbstractBeccaEntity = require('./abstract_becca_entity'); | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import utils = require('../../services/utils'); | import utils = require('../../services/utils'); | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext = require('../../services/task_context'); | ||||||
| import cls = require('../../services/cls'); | import cls = require('../../services/cls'); | ||||||
| import log = require('../../services/log'); | import log = require('../../services/log'); | ||||||
| import { BranchRow } from './rows.js'; | import { BranchRow } from './rows'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 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 | ||||||
| @ -159,7 +159,7 @@ 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.js'); |                 const handlers = require('../../services/handlers'); | ||||||
|                 handlers.runAttachedRelations(note, 'runOnNoteDeletion', note); |                 handlers.runAttachedRelations(note, 'runOnNoteDeletion', note); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import log = require('../../services/log'); | |||||||
| import sql = require('../../services/sql'); | import sql = require('../../services/sql'); | ||||||
| import utils = require('../../services/utils'); | import utils = require('../../services/utils'); | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity.js'); | import AbstractBeccaEntity = require('./abstract_becca_entity'); | ||||||
| import BRevision = require('./brevision'); | import BRevision = require('./brevision'); | ||||||
| import BAttachment = require('./battachment'); | import BAttachment = require('./battachment'); | ||||||
| import TaskContext = require('../../services/task_context'); | import TaskContext = require('../../services/task_context'); | ||||||
| @ -896,7 +896,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             const searchService = require('../../services/search/services/search.js'); |             const searchService = require('../../services/search/services/search'); | ||||||
|             const {searchResultNoteIds} = searchService.searchFromNote(this); |             const {searchResultNoteIds} = searchService.searchFromNote(this); | ||||||
| 
 | 
 | ||||||
|             const becca = this.becca; |             const becca = this.becca; | ||||||
| @ -1284,7 +1284,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         else { |         else { | ||||||
|             const BAttribute = require('./battribute.js'); |             const BAttribute = require('./battribute'); | ||||||
| 
 | 
 | ||||||
|             new BAttribute({ |             new BAttribute({ | ||||||
|                 noteId: this.noteId, |                 noteId: this.noteId, | ||||||
| @ -1321,7 +1321,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|      * @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: string, name: string, value: string = "", isInheritable: boolean = false, position: number | null = null): BAttribute { | ||||||
|         const BAttribute = require('./battribute.js'); |         const BAttribute = require('./battribute'); | ||||||
| 
 | 
 | ||||||
|         return new BAttribute({ |         return new BAttribute({ | ||||||
|             noteId: this.noteId, |             noteId: this.noteId, | ||||||
| @ -1433,7 +1433,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     searchNotesInSubtree(searchString: string) { |     searchNotesInSubtree(searchString: string) { | ||||||
|         const searchService = require('../../services/search/services/search.js'); |         const searchService = require('../../services/search/services/search'); | ||||||
| 
 | 
 | ||||||
|         return searchService.searchNotes(searchString); |         return searchService.searchNotes(searchString); | ||||||
|     } |     } | ||||||
| @ -1443,7 +1443,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     cloneTo(parentNoteId: string) { |     cloneTo(parentNoteId: string) { | ||||||
|         const cloningService = require('../../services/cloning.js'); |         const cloningService = require('../../services/cloning'); | ||||||
| 
 | 
 | ||||||
|         const branch = this.becca.getNote(parentNoteId).getParentBranches()[0]; |         const branch = this.becca.getNote(parentNoteId).getParentBranches()[0]; | ||||||
| 
 | 
 | ||||||
| @ -1514,7 +1514,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
| 
 | 
 | ||||||
|         parentNote.setContent(fixedContent); |         parentNote.setContent(fixedContent); | ||||||
| 
 | 
 | ||||||
|         const noteService = require('../../services/notes.js'); |         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(); | ||||||
| @ -1541,7 +1541,7 @@ 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.js'); |         const handlers = require('../../services/handlers'); | ||||||
|         handlers.runAttachedRelations(this, 'runOnNoteDeletion', this); |         handlers.runAttachedRelations(this, 'runOnNoteDeletion', this); | ||||||
|         taskContext.noteDeletionHandlerTriggered = true; |         taskContext.noteDeletionHandlerTriggered = true; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity.js'); | import AbstractBeccaEntity = require('./abstract_becca_entity'); | ||||||
| import { OptionRow } from './rows'; | import { OptionRow } from './rows'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
| import { RecentNoteRow } from "./rows"; | import { RecentNoteRow } from "./rows"; | ||||||
| 
 | 
 | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity.js'); | import AbstractBeccaEntity = require('./abstract_becca_entity'); | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * RecentNote represents recently visited note. |  * RecentNote represents recently visited note. | ||||||
|  | |||||||
| @ -3,10 +3,10 @@ | |||||||
| import protectedSessionService = require('../../services/protected_session'); | import protectedSessionService = require('../../services/protected_session'); | ||||||
| import utils = require('../../services/utils'); | import utils = require('../../services/utils'); | ||||||
| import dateUtils = require('../../services/date_utils'); | import dateUtils = require('../../services/date_utils'); | ||||||
| import becca = require('../becca.js'); | import becca = require('../becca'); | ||||||
| import AbstractBeccaEntity = require('./abstract_becca_entity.js'); | import AbstractBeccaEntity = require('./abstract_becca_entity'); | ||||||
| import sql = require('../../services/sql'); | import sql = require('../../services/sql'); | ||||||
| import BAttachment = require('./battachment.js'); | import BAttachment = require('./battachment'); | ||||||
| import { AttachmentRow, RevisionRow } from './rows'; | import { AttachmentRow, RevisionRow } from './rows'; | ||||||
| 
 | 
 | ||||||
| interface ContentOpts { | interface ContentOpts { | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| const BAttachment = require('./entities/battachment.js'); | const BAttachment = require('./entities/battachment'); | ||||||
| const BAttribute = require('./entities/battribute.js'); | const BAttribute = require('./entities/battribute'); | ||||||
| const BBlob = require('./entities/bblob.js'); | const BBlob = require('./entities/bblob'); | ||||||
| const BBranch = require('./entities/bbranch.js'); | const BBranch = require('./entities/bbranch'); | ||||||
| const BEtapiToken = require('./entities/betapi_token.js'); | const BEtapiToken = require('./entities/betapi_token'); | ||||||
| const BNote = require('./entities/bnote.js'); | const BNote = require('./entities/bnote'); | ||||||
| const BOption = require('./entities/boption.js'); | const BOption = require('./entities/boption'); | ||||||
| const BRecentNote = require('./entities/brecent_note.js'); | const BRecentNote = require('./entities/brecent_note'); | ||||||
| const BRevision = require('./entities/brevision.js'); | const BRevision = require('./entities/brevision'); | ||||||
| 
 | 
 | ||||||
| const ENTITY_NAME_TO_ENTITY = { | const ENTITY_NAME_TO_ENTITY = { | ||||||
|     "attachments": BAttachment, |     "attachments": BAttachment, | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| const becca = require('./becca.js'); | const becca = require('./becca'); | ||||||
| const log = require('../services/log'); | const log = require('../services/log'); | ||||||
| const beccaService = require('./becca_service.js'); | const beccaService = require('./becca_service'); | ||||||
| const dateUtils = require('../services/date_utils'); | const dateUtils = require('../services/date_utils'); | ||||||
| const {JSDOM} = require("jsdom"); | const {JSDOM} = require("jsdom"); | ||||||
| 
 | 
 | ||||||
| @ -35,7 +35,7 @@ const IGNORED_ATTR_NAMES = [ | |||||||
| function filterUrlValue(value) { | function filterUrlValue(value) { | ||||||
|     return value |     return value | ||||||
|         .replace(/https?:\/\//ig, "") |         .replace(/https?:\/\//ig, "") | ||||||
|         .replace(/www.js\./ig, "") |         .replace(/www\./ig, "") | ||||||
|         .replace(/(\.net|\.com|\.org|\.info|\.edu)/ig, ""); |         .replace(/(\.net|\.com|\.org|\.info|\.edu)/ig, ""); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran