diff --git a/src/services/BaseEntityService.ts b/src/services/BaseEntityService.ts index a2f05d6..af7544b 100644 --- a/src/services/BaseEntityService.ts +++ b/src/services/BaseEntityService.ts @@ -245,6 +245,7 @@ export interface IModelSchema { keys: IColumn[]; properties: IColumn[]; relations: IRelation[]; + readonly methods?: string[]; } export interface IModel { @@ -340,7 +341,7 @@ export default abstract class BaseEntityService extends HttpSession { } public query(m: IModel, - queryFunction?: string, + queryFunction?: IModel["schema"]["methods"][number], ... args: any[]): Query { return new Query({ service: this, @@ -361,6 +362,17 @@ export default abstract class BaseEntityService extends HttpSession { return this.putJson({url, body}); } + public invoke(m: IModel, method: IModel["schema"]["methods"][number],entity: IClrEntity, ... args: any[]) { + return this.postJson({ + url: `${this.url}invoke/${entity.$type}/${name}`, + method: "POST", + body: { + entity, + args + } + }); + } + public save(body: T, cloner?: (c: Cloner) => Cloner, trace?: boolean): Promise; public save(body: T[], cloner?: (c: Cloner) => Cloner, trace?: boolean): Promise; public async save(body: any, cloner?: (c: Cloner) => Cloner, trace?: boolean): Promise {