import { ConsoleGetCompletionTypesResponse, ConsoleGetPropertiesResponse, ConsoleRequestBookmarksResponse, ConsoleRequestHistoryResponse, ConsoleRequestSearchEnginesResponse, ConsoleRequesttabsResponse, } from "../../shared/messages"; import { injectable } from "tsyringe"; import OpenCompletionUseCase from "../completion/OpenCompletionUseCase"; import TabCompletionUseCase from "../completion/TabCompletionUseCase"; import PropertyCompletionUseCase from "../completion/PropertyCompletionUseCase"; @injectable() export default class CompletionController { constructor( private completionUseCase: OpenCompletionUseCase, private tabCompletionUseCase: TabCompletionUseCase, private propertyCompletionUseCase: PropertyCompletionUseCase ) {} async getCompletionTypes(): Promise { return this.completionUseCase.getCompletionTypes(); } async requestSearchEngines( query: string ): Promise { const items = await this.completionUseCase.requestSearchEngines(query); return items.map((name) => ({ title: name })); } async requestBookmarks( query: string ): Promise { return this.completionUseCase.requestBookmarks(query); } async requestHistory(query: string): Promise { return this.completionUseCase.requestHistory(query); } async queryTabs( query: string, excludePinned: boolean ): Promise { return this.tabCompletionUseCase.queryTabs(query, excludePinned); } async getProperties(): Promise { return this.propertyCompletionUseCase.getProperties(); } }