UNPKG

@n1k1t/mock-server

Version:

Powerful util to setup mocks over HTTP APIs

49 lines 2.48 kB
import { ReplaySubject } from 'rxjs'; import type { IRequestContextIncoming, IRequestContextOutgoing, TRequestContextCacheConfigurationCompiled } from './types'; import type { IServerContext } from '../../types'; import type { Expectation } from '../../../expectations'; import type { Provider } from '../providers'; import type { History } from '../history'; import { RequestContextSnapshot } from './snapshot'; export * from './snapshot'; export * from './types'; export * from './utils'; export declare abstract class RequestContext<TContext extends IServerContext = IServerContext> { provider: Provider<IServerContext>; protected configuration: Pick<TContext, 'transport' | 'event'>; TContext: TContext; TShared: keyof Pick<RequestContext, 'incoming' | 'outgoing' | 'snapshot' | 'expectation' | 'history'>; abstract incoming: IRequestContextIncoming; abstract snapshot: RequestContextSnapshot<TContext>; status: "registered" | "handling" | "skipped" | "completed"; streams: { incoming: ReplaySubject<unknown>; outgoing: ReplaySubject<unknown>; }; transport: TContext['transport']; event: TContext['event']; flags: Partial<Record<TContext['flag'], boolean>>; expectation?: Expectation<any>; outgoing?: IRequestContextOutgoing; history?: History; timestamp: number; meta: import("../../../meta").MetaContext; constructor(provider: Provider<IServerContext>, configuration: Pick<TContext, 'transport' | 'event'>); switchStatus(status: RequestContext['status']): this; hasStatuses(status: RequestContext['status'][]): boolean; /** Compiles snapshot of own payload to work with expectations */ compileSnapshot(): RequestContextSnapshot<TContext>; /** Compiles history model with own snapshot for GUI */ compileHistory(): History; /** Compiles cache configuration using own snapshot and expectation */ compileCacheConfiguration(): TRequestContextCacheConfigurationCompiled; /** Provides payload parts into context */ assign<T extends Partial<Pick<RequestContext<any>, RequestContext<any>['TShared']>>>(payload: T): this; /** Marks context as skipped to prevent further handling in executors */ skip(): this; /** Marks context as handling */ handle(): this; /** Marks context as completed, completes streams, provides outgoing payload from the own snapshot and publishes history */ complete(): this; } //# sourceMappingURL=index.d.ts.map