import { BaseSearch , ProcessedSearchEntry , SearcherFactory } from "./BaseSearch" ; import Vault from "../core/Vault" ; import Entry from "../core/Entry" ; import { EntryURLType , getEntryURLs } from "../tools/entry" ; import StorageInterface from "../storage/StorageInterface" ; async function extractEntries ( vault , memory ) { const scoresRaw = await memory . getValue ( `bcup_search_${ vault . id }` ) ; let vaultScore = { } ; if ( scoresRaw ) { try { const scores = JSON . parse ( scoresRaw ) ; vaultScore = scores ; } catch ( err ) { } } return vault . getAllEntries ( ) . filter ( ( entry ) => entry . isInTrash ( ) === false ) . map ( ( entry ) => { const properties = entry . getProperties ( ) ; const urls = getEntryURLs ( properties , EntryURLType . General ) ; return { id : entry . id , properties , entryType : entry . getType ( ) , urls , groupID : entry . getGroup ( ) . id , vaultID : vault . id , domainScores : vaultScore [ entry . id ] || { } } ; } ) ; } export class VaultEntrySearch extends BaseSearch { constructor ( vaults , memory ? , searcherFactory ? ) { super ( vaults , extractEntries , memory , searcherFactory ) ; } }