import Core, { CoreExport, CoreImport, CoreSearch, CoreUser } from "../api.ts"; import YomikunError from "../../util/error.ts"; import Search from "../../search/search.ts"; import DB from "../../db/db.ts"; /** @summary internal Core (DO NOT USE DIRECTLY) */ export default class RawCore implements Core { public ready: Promise; private _search: Search; private _db: DB; constructor() { if (this.constructor === RawCore) { throw new YomikunError("RawCore instantiated! Use DirectCoreClient instead!"); } this._db = new DB(); this._search = new Search(this._db); this.ready = new Promise(async resolve => { await this._search.ready; resolve(); }) } public search: CoreSearch = { terms: async term => { return await this._search.terms(term); }, sentence: async (sentence, optional?) => { return await this._search.sentence(sentence, optional); }, }; public user: CoreUser = { termPriority: async (uid, expression, reading, priority) => { this._db.termPriority(uid, expression, reading, priority); }, }; public import: CoreImport = {}; public export: CoreExport = {}; };