diff options
Diffstat (limited to 'core/http/client.ts')
-rw-r--r-- | core/http/client.ts | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/core/http/client.ts b/core/http/client.ts index 6b4e1a3..80f77b3 100644 --- a/core/http/client.ts +++ b/core/http/client.ts @@ -1,10 +1,8 @@ -import { InputSentenceProps } from "../../language/types.ts"; import "../../util/array.ts"; -import { DeepPartial } from "../../util/types.ts"; -import Core from "../api.ts"; +import Core, { CoreExport, CoreImport, CoreSearch, CoreUser } from "../api.ts"; import { ConnectionProps, ConnectionPropsDefault } from "./props.ts"; -import { CoreRequest, CoreRequestParseSentence, CoreResponseParseSentence } from "./types.ts"; +import { CoreRequest, CoreRequestSearchSentence, CoreRequestSearchTerms, CoreResponseSearchSentence, CoreResponseSearchTerms } from "./types.ts"; /** * @summary HTTP Core client @@ -13,8 +11,9 @@ import { CoreRequest, CoreRequestParseSentence, CoreResponseParseSentence } from * (de)serialization automatically. */ export default class RemoteCoreClient implements Core { + public ready: Promise<void> = Promise.resolve(); + private props: ConnectionProps; - ready: Promise<void> = Promise.resolve(); constructor(options?: ConnectionProps) { this.props = { ...ConnectionPropsDefault, ...options }; @@ -32,13 +31,29 @@ export default class RemoteCoreClient implements Core { return response.json(); } - async parseSentence(input: string, options?: DeepPartial<InputSentenceProps>) { - var request: CoreRequestParseSentence = { - command: "parseSentence", - options: { input, options, }, - }; - var { response } = await this.request(request) as CoreResponseParseSentence; - return response; - } + public search: CoreSearch = { + terms: async term => { + var request: CoreRequestSearchTerms = { + command: "search.terms", + options: { term, }, + }; + var { response } = await this.request(request) as CoreResponseSearchTerms; + return response; + }, + sentence: async (sentence, optional?) => { + var request: CoreRequestSearchSentence = { + command: "search.sentence", + options: { sentence, optional, }, + }; + var { response } = await this.request(request) as CoreResponseSearchSentence; + return response; + }, + }; + + public user: CoreUser = {}; + + public import: CoreImport = {}; + + public export: CoreExport = {}; } |