Update lunr type (#93)

This commit is contained in:
mtgto 2020-04-15 04:16:18 +09:00 committed by GitHub
parent e9db844285
commit 8438cafbd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 deletions

6
package-lock.json generated
View File

@ -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": {

View File

@ -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",

View File

@ -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();