mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
Update lunr type (#93)
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -304,9 +304,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/lunr": {
|
"@types/lunr": {
|
||||||
"version": "2.1.6",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.3.3.tgz",
|
||||||
"integrity": "sha512-Bz6fUhX1llTa7ygQJN3ttoVkkrpW7xxSEP7D7OYFO/FCBKqKqruRUZtJzTtYA0GkQX13lxU5u+8LuCviJlAXkQ==",
|
"integrity": "sha512-09sXZZVsB3Ib41U0fC+O1O+4UOZT1bl/e+/QubPxpqDWHNEchvx/DEb1KJMOwq6K3MTNzZFoNSzVdR++o1DVnw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
"@types/inquirer": "^0.0.43",
|
"@types/inquirer": "^0.0.43",
|
||||||
"@types/jasmine": "^3.3.12",
|
"@types/jasmine": "^3.3.12",
|
||||||
"@types/lowdb": "^1.0.5",
|
"@types/lowdb": "^1.0.5",
|
||||||
"@types/lunr": "^2.1.6",
|
"@types/lunr": "^2.3.3",
|
||||||
"@types/node": "^10.9.4",
|
"@types/node": "^10.9.4",
|
||||||
"@types/node-fetch": "^2.1.2",
|
"@types/node-fetch": "^2.1.2",
|
||||||
"@types/node-forge": "^0.7.5",
|
"@types/node-forge": "^0.7.5",
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ export class SearchService implements SearchServiceAbstraction {
|
|||||||
this.index = null;
|
this.index = null;
|
||||||
const builder = new lunr.Builder();
|
const builder = new lunr.Builder();
|
||||||
builder.ref('id');
|
builder.ref('id');
|
||||||
(builder as any).field('shortid', { boost: 100, extractor: (c: CipherView) => c.id.substr(0, 8) });
|
builder.field('shortid', { boost: 100, extractor: (c: CipherView) => c.id.substr(0, 8) });
|
||||||
(builder as any).field('name', { boost: 10 });
|
builder.field('name', { boost: 10 });
|
||||||
(builder as any).field('subtitle', {
|
builder.field('subtitle', {
|
||||||
boost: 5,
|
boost: 5,
|
||||||
extractor: (c: CipherView) => {
|
extractor: (c: CipherView) => {
|
||||||
if (c.subTitle != null && c.type === CipherType.Card) {
|
if (c.subTitle != null && c.type === CipherType.Card) {
|
||||||
@@ -53,16 +53,16 @@ export class SearchService implements SearchServiceAbstraction {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
builder.field('notes');
|
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,
|
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.field('login.uris', { boost: 2, extractor: (c: CipherView) => this.uriExtractor(c) });
|
||||||
(builder as any).field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) });
|
builder.field('fields', { extractor: (c: CipherView) => this.fieldExtractor(c, false) });
|
||||||
(builder as any).field('fields_joined', { extractor: (c: CipherView) => this.fieldExtractor(c, true) });
|
builder.field('fields_joined', { extractor: (c: CipherView) => this.fieldExtractor(c, true) });
|
||||||
(builder as any).field('attachments', { extractor: (c: CipherView) => this.attachmentExtractor(c, false) });
|
builder.field('attachments', { extractor: (c: CipherView) => this.attachmentExtractor(c, false) });
|
||||||
(builder as any).field('attachments_joined',
|
builder.field('attachments_joined',
|
||||||
{ extractor: (c: CipherView) => this.attachmentExtractor(c, true) });
|
{ 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();
|
const ciphers = await this.cipherService.getAllDecrypted();
|
||||||
ciphers.forEach((c) => builder.add(c));
|
ciphers.forEach((c) => builder.add(c));
|
||||||
this.index = builder.build();
|
this.index = builder.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user