diff --git a/package-lock.json b/package-lock.json index 8479e6546..95111a5b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -304,9 +304,9 @@ } }, "@types/lunr": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.1.6.tgz", - "integrity": "sha512-Bz6fUhX1llTa7ygQJN3ttoVkkrpW7xxSEP7D7OYFO/FCBKqKqruRUZtJzTtYA0GkQX13lxU5u+8LuCviJlAXkQ==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.3.3.tgz", + "integrity": "sha512-09sXZZVsB3Ib41U0fC+O1O+4UOZT1bl/e+/QubPxpqDWHNEchvx/DEb1KJMOwq6K3MTNzZFoNSzVdR++o1DVnw==", "dev": true }, "@types/node": { diff --git a/package.json b/package.json index d10190ecc..5fec1f566 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@types/inquirer": "^0.0.43", "@types/jasmine": "^3.3.12", "@types/lowdb": "^1.0.5", - "@types/lunr": "^2.1.6", + "@types/lunr": "^2.3.3", "@types/node": "^10.9.4", "@types/node-fetch": "^2.1.2", "@types/node-forge": "^0.7.5", diff --git a/src/services/search.service.ts b/src/services/search.service.ts index 4a994c411..a7149cafb 100644 --- a/src/services/search.service.ts +++ b/src/services/search.service.ts @@ -41,9 +41,9 @@ export class SearchService implements SearchServiceAbstraction { this.index = null; const builder = new lunr.Builder(); builder.ref('id'); - (builder as any).field('shortid', { boost: 100, extractor: (c: CipherView) => c.id.substr(0, 8) }); - (builder as any).field('name', { boost: 10 }); - (builder as any).field('subtitle', { + builder.field('shortid', { boost: 100, extractor: (c: CipherView) => c.id.substr(0, 8) }); + builder.field('name', { boost: 10 }); + builder.field('subtitle', { boost: 5, extractor: (c: CipherView) => { if (c.subTitle != null && c.type === CipherType.Card) { @@ -53,16 +53,16 @@ export class SearchService implements SearchServiceAbstraction { }, }); builder.field('notes'); - (builder as any).field('login.username', { + builder.field('login.username', { extractor: (c: CipherView) => c.type === CipherType.Login && c.login != null ? c.login.username : null, }); - (builder as any).field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) }); - (builder as any).field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) }); - (builder as any).field('fields_joined', { extractor: (c: CipherView) => this.fieldExtractor(c, true) }); - (builder as any).field('attachments', { extractor: (c: CipherView) => this.attachmentExtractor(c, false) }); - (builder as any).field('attachments_joined', + builder.field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) }); + builder.field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) }); + builder.field('fields_joined', { extractor: (c: CipherView) => this.fieldExtractor(c, true) }); + builder.field('attachments', { extractor: (c: CipherView) => this.attachmentExtractor(c, false) }); + builder.field('attachments_joined', { extractor: (c: CipherView) => this.attachmentExtractor(c, true) }); - (builder as any).field('organizationid', { extractor: (c: CipherView) => c.organizationId }); + builder.field('organizationid', { extractor: (c: CipherView) => c.organizationId }); const ciphers = await this.cipherService.getAllDecrypted(); ciphers.forEach((c) => builder.add(c)); this.index = builder.build();