diff --git a/src/services/BaseEntityService.ts b/src/services/BaseEntityService.ts index 964d007..47b0e28 100644 --- a/src/services/BaseEntityService.ts +++ b/src/services/BaseEntityService.ts @@ -248,7 +248,7 @@ export interface IModelSchema { methods?: { [key: string]: any }; } -export interface IModel { +export interface IModel { name: string; create?(properties?: IClrEntityLike): T; patch?(original: IClrEntityLike, updates: IClrEntityLike): T; @@ -344,8 +344,8 @@ export default abstract class BaseEntityService extends HttpSession { ]); } - public query(m: IModel, - queryFunction?: InferSchemaMethod>, + public query(m: IModel, + queryFunction?: keyof TR, ... args: any[]): Query { return new Query({ service: this, @@ -366,9 +366,9 @@ export default abstract class BaseEntityService extends HttpSession { return this.putJson({url, body}); } - public invoke(m: IModel, method: InferSchemaMethod>,entity: IClrEntity, ... args: any[]) { + public invoke(m: IModel, method: keyof TR,entity: IClrEntity, ... args: any[]) { return this.postJson({ - url: `${this.url}invoke/${entity.$type}/${method}`, + url: `${this.url}invoke/${entity.$type}/${method as any}`, method: "POST", body: { entity, diff --git a/src/tests/schema-test/SchemaTest.test.ts b/src/tests/schema-test/SchemaTest.test.ts new file mode 100644 index 0000000..44193ee --- /dev/null +++ b/src/tests/schema-test/SchemaTest.test.ts @@ -0,0 +1,32 @@ +import BaseEntityService, { IModel, Model } from "../../services/BaseEntityService"; +import HttpSession from "../../services/HttpSession"; +import { QueryProcessor } from "../../services/QueryProcessor"; + +interface IItem { + $type: string, name: string, desc: string +} + +const m1: IModel = new Model( + "n1", + ["name"], + void 0, + { + keys: [ { name:"name" }], + name: "n1", + properties: [ { name: "desc"}], + relations: [], + methods: { + run: "run" + } + } +); + +class EnttiyService extends BaseEntityService { + + public queryProcessor: QueryProcessor; + +} + +const es = new EnttiyService(); + +es.query(m1, "run"); \ No newline at end of file