@n1k1t/mock-server
Version:
The ultimate toolkit to intercept, transform, and simulate HTTP/WS traffic with type-safe expectations
53 lines • 2.62 kB
TypeScript
import { ReplaySubject } from 'rxjs';
import type { IServerContext } from '../../types';
import type { RequestMessage } from '../message';
import type { Expectation } from '../../../expectations';
import type { Provider } from '../providers';
import type { History } from '../history';
import type { IRequestContextIncoming, IRequestContextOutgoing, TRequestContextCacheConfigurationCompiled } from './types';
import { RequestContextSnapshot } from './snapshot';
export * from './snapshot';
export * from './types';
export * from './utils';
export declare abstract class RequestContext<TContext extends IServerContext = any> {
provider: Provider;
protected configuration: Pick<TContext, 'transport'>;
TContext: TContext;
TShared: keyof Pick<RequestContext, 'incoming' | 'outgoing' | 'snapshot' | 'expectation' | 'history'>;
abstract incoming: IRequestContextIncoming;
abstract snapshot: RequestContextSnapshot<TContext>;
status: "registered" | "handling" | "skipped" | "completed" | "canceled";
streams: {
incoming: ReplaySubject<RequestMessage<any>>;
outgoing: ReplaySubject<RequestMessage<any>>;
};
transport: TContext['transport'];
flags: Partial<Record<TContext['flag'], boolean>>;
expectation?: Expectation;
outgoing?: IRequestContextOutgoing;
history?: History;
timestamp: number;
meta: import("../../../meta").MetaContext;
constructor(provider: Provider, configuration: Pick<TContext, 'transport'>);
/** Switches to status */
switch(status: RequestContext['status']): this;
/** Checks context is in provided statuses */
is(statuses: 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 canceled and unregisters history */
cancel(): this;
/** Marks context as completed, completes streams, provides outgoing payload from the own snapshot and publishes history */
complete(): this;
}
//# sourceMappingURL=index.d.ts.map