Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
server-ts: Convert attribute_formatter
Elian Dorana183f21078c9
diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.jsindex ea4fb64c3e..2490518871 100644--- a/src/routes/api/clipper.js+++ b/src/routes/api/clipper.js@@ -12,7 +12,7 @@ const log = require('../../services/log');const utils = require('../../services/utils');const path = require('path');const htmlSanitizer = require('../../services/html_sanitizer.js');-const {formatAttrForSearch} = require('../../services/attribute_formatter.js');+const {formatAttrForSearch} = require('../../services/attribute_formatter');const jsdom = require("jsdom");const { JSDOM } = jsdom;diff --git a/src/routes/api/search.js b/src/routes/api/search.jsindex b98e085177..a582dafcd4 100644--- a/src/routes/api/search.js+++ b/src/routes/api/search.js@@ -5,7 +5,7 @@ const SearchContext = require('../../services/search/search_context.js');const searchService = require('../../services/search/services/search.js');const bulkActionService = require('../../services/bulk_actions.js');const cls = require('../../services/cls');-const {formatAttrForSearch} = require('../../services/attribute_formatter.js');+const {formatAttrForSearch} = require('../../services/attribute_formatter');const ValidationError = require('../../errors/validation_error');function searchFromNote(req) {diff --git a/src/services/attribute_formatter.js b/src/services/attribute_formatter.tssimilarity index 83%rename from src/services/attribute_formatter.jsrename to src/services/attribute_formatter.tsindex c8a9c1de61..846450f36e 100644--- a/src/services/attribute_formatter.js+++ b/src/services/attribute_formatter.ts@@ -1,6 +1,8 @@"use strict";-function formatAttrForSearch(attr, searchWithValue) {+import BAttribute = require("../becca/entities/battribute");++function formatAttrForSearch(attr: BAttribute, searchWithValue: string) {let searchStr = '';if (attr.type === 'label') {@@ -27,7 +29,7 @@ function formatAttrForSearch(attr, searchWithValue) {return searchStr;}-function formatValue(val) {+function formatValue(val: string) {if (!/[^\w]/.test(val)) {return val;}@@ -45,6 +47,6 @@ function formatValue(val) {}}-module.exports = {+export = {formatAttrForSearch};diff --git a/src/services/attributes.js b/src/services/attributes.jsindex 69e12faa1d..fc527429c9 100644--- a/src/services/attributes.js+++ b/src/services/attributes.js@@ -4,7 +4,7 @@ const searchService = require('./search/services/search.js');const sql = require('./sql');const becca = require('../becca/becca');const BAttribute = require('../becca/entities/battribute');-const {formatAttrForSearch} = require('./attribute_formatter.js');+const {formatAttrForSearch} = require('./attribute_formatter');const BUILTIN_ATTRIBUTES = require('./builtin_attributes');const ATTRIBUTE_TYPES = ['label', 'relation'];