import { RequestContext } from "../context/request-context"; export class EngineAbortPromise { abort: () => void; promise: Promise; then: Promise["then"]; catch: Promise["catch"]; finally: Promise["finally"]; constructor(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void, abort: () => void) { this.promise = new Promise(executor); this.then = this.promise.then.bind(this.promise); this.catch = this.promise.catch.bind(this.promise); this.finally = this.promise.finally.bind(this.promise); this.abort = abort; } } export abstract class Engine { static EngineAbortPromise = EngineAbortPromise; abstract doRequest(requestContext: RequestContext): Promise | EngineAbortPromise; abstract doResponse( response: Response, requestContext: RequestContext ): Promise<{ ok: boolean; status: string | number; statusText: string; result: any }>; }