diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/api.ts | 5 | ||||
-rw-r--r-- | core/http/client.ts | 8 | ||||
-rw-r--r-- | core/http/server.ts | 3 | ||||
-rw-r--r-- | core/http/types.ts | 4 | ||||
-rw-r--r-- | core/raw/api.ts | 14 |
5 files changed, 20 insertions, 14 deletions
diff --git a/core/api.ts b/core/api.ts index 51f976a..0720c8b 100644 --- a/core/api.ts +++ b/core/api.ts @@ -1,4 +1,5 @@ -import { ParseResult } from "../language/types.ts"; +import { InputSentenceProps, ParseResult } from "../language/types.ts"; +import { DeepPartial } from "../util/types.ts"; /** * @summary Core interface @@ -12,6 +13,6 @@ export default abstract class Core { abstract ready: Promise<void>; /** @summary parse sentence */ - abstract parseSentence(input: string): Promise<ParseResult>; + abstract parseSentence(input: string, options?: DeepPartial<InputSentenceProps>): Promise<ParseResult>; }; diff --git a/core/http/client.ts b/core/http/client.ts index 118e8f5..6b4e1a3 100644 --- a/core/http/client.ts +++ b/core/http/client.ts @@ -1,4 +1,6 @@ +import { InputSentenceProps } from "../../language/types.ts"; import "../../util/array.ts"; +import { DeepPartial } from "../../util/types.ts"; import Core from "../api.ts"; import { ConnectionProps, ConnectionPropsDefault } from "./props.ts"; @@ -30,12 +32,10 @@ export default class RemoteCoreClient implements Core { return response.json(); } - async parseSentence(input: string) { + async parseSentence(input: string, options?: DeepPartial<InputSentenceProps>) { var request: CoreRequestParseSentence = { command: "parseSentence", - options: { - input: input, - }, + options: { input, options, }, }; var { response } = await this.request(request) as CoreResponseParseSentence; return response; diff --git a/core/http/server.ts b/core/http/server.ts index 0a9a082..7781a22 100644 --- a/core/http/server.ts +++ b/core/http/server.ts @@ -13,10 +13,11 @@ export default class RemoteCoreServer extends RawCore { parseSentence: async _req => { var req = _req as CoreRequestParseSentence; var input = req.options?.input + var options = req.options?.options; if (!input) return new Response("", { status: 404 }); return new Response(JSON.stringify({ command: "parseSentence", - response: await this.parseSentence(input), + response: await this.parseSentence(input, options), } as CoreResponseParseSentence)); }, }; diff --git a/core/http/types.ts b/core/http/types.ts index af2cfea..3d55a98 100644 --- a/core/http/types.ts +++ b/core/http/types.ts @@ -1,4 +1,5 @@ -import { ParseResult } from "../../language/types.ts"; +import { InputSentenceProps, ParseResult } from "../../language/types.ts"; +import { DeepPartial } from "../../util/types.ts"; export interface CoreRequest { command: string; @@ -9,6 +10,7 @@ export interface CoreRequestParseSentence extends CoreRequest { command: "parseSentence"; options: { input: string; + options?: DeepPartial<InputSentenceProps>; }; }; diff --git a/core/raw/api.ts b/core/raw/api.ts index f47dead..593b932 100644 --- a/core/raw/api.ts +++ b/core/raw/api.ts @@ -1,27 +1,29 @@ import Core from "../api.ts"; import Parser from "../../language/parser.ts"; import YomikunError from "../../util/error.ts"; +import { DeepPartial } from "../../util/types.ts"; +import { InputSentenceProps } from "../../language/types.ts"; /** @summary internal Core (DO NOT USE DIRECTLY) */ export default class RawCore implements Core { - private _parser: Parser; - ready: Promise<void>; + private parser: Parser; + public ready: Promise<void>; constructor() { if (this.constructor === RawCore) { throw new YomikunError("RawCore instantiated! Use DirectCoreClient instead!"); } - this._parser = new Parser(); + this.parser = new Parser(); this.ready = new Promise(async resolve => { - await this._parser.ready; + await this.parser.ready; resolve(); }) } - async parseSentence(input: string) { - return await this._parser.parse(input); + async parseSentence(input: string, options?: DeepPartial<InputSentenceProps>) { + return await this.parser.parse(input, options); } }; |