import { isOpenAPIObject , OpenAPIObject } from "loas3/dist/generated/full" ; import { ISerializedRequest , IStateTransformer } from "../interfaces" ; import { IService , IServiceCore } from "./interfaces" ; import { ServiceCore } from "./serviceCore" ; import { ServiceSpy } from "./spy" ; export class Service implements IService { param param0 public static fromOpenAPI ( { schema , name , } ) { const core = new ServiceCore ( { schema , name } ) ; return new Service ( core ) ; } public static isOpenAPIObject ( schema ) { return isOpenAPIObject ( schema ) ; } public readonly spy : ServiceSpy ; constructor ( public readonly core ) { this . spy = core . spy ; } public state ( a0 , ... i ) { this . core . transformer = ( req , o ) : OpenAPIObject => i . reduce ( ( a , b ) => b ( req , a ) , a0 ( req , o ) ) ; } public reset ( ) { this . spy . resetHistory ( ) ; this . core . transformer = ( _ , b ) => b ; } }