Skip to content

Commit

Permalink
fix: Update types for class methods (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
redabacha authored Dec 10, 2021
1 parent dab6789 commit b88655a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 55 deletions.
48 changes: 21 additions & 27 deletions packages/@pollyjs/adapter/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,32 @@ export default class Adapter<
readonly defaultOptions: TOptions;
readonly options: TOptions;
persister: Polly['persister'];
connect: () => void;
onConnect: () => void;
disconnect: () => void;
onDisconnect: () => void;
private timeout: (
request: TRequest,
options: { time: number }
) => Promise<void>;
handleRequest: (
connect(): void;
onConnect(): void;
disconnect(): void;
onDisconnect(): void;
private timeout(request: TRequest, options: { time: number }): Promise<void>;
handleRequest(
request: Pick<
TRequest,
'url' | 'method' | 'headers' | 'body' | 'requestArguments'
>
) => Promise<TRequest>;
private passthrough: (request: TRequest) => Promise<void>;
onPassthrough: (request: TRequest) => Promise<void>;
private intercept: (
request: TRequest,
interceptor: Interceptor
) => Promise<void>;
onIntercept: (request: TRequest, interceptor: Interceptor) => Promise<void>;
private record: (request: TRequest) => Promise<void>;
onRecord: (request: TRequest) => Promise<void>;
private replay: (request: TRequest) => Promise<void>;
onReplay: (request: TRequest) => Promise<void>;
assert: (message: string, condition?: boolean) => void;
): Promise<TRequest>;
private passthrough(request: TRequest): Promise<void>;
onPassthrough(request: TRequest): Promise<void>;
private intercept(request: TRequest, interceptor: Interceptor): Promise<void>;
onIntercept(request: TRequest, interceptor: Interceptor): Promise<void>;
private record(request: TRequest): Promise<void>;
onRecord(request: TRequest): Promise<void>;
private replay(request: TRequest): Promise<void>;
onReplay(request: TRequest): Promise<void>;
assert(message: string, condition?: boolean): void;
onFetchResponse(
pollyRequest: TRequest
): Promise<Pick<Response, 'statusCode' | 'headers' | 'body' | 'encoding'>>;
onRespond: (request: TRequest, error?: Error) => Promise<void>;
onIdentifyRequest: (request: TRequest) => Promise<void>;
onRequest: (request: TRequest) => Promise<void>;
onRequestFinished: (request: TRequest) => Promise<void>;
onRequestFailed: (request: TRequest) => Promise<void>;
onRespond(request: TRequest, error?: Error): Promise<void>;
onIdentifyRequest(request: TRequest): Promise<void>;
onRequest(request: TRequest): Promise<void>;
onRequestFinished(request: TRequest): Promise<void>;
onRequestFailed(request: TRequest): Promise<void>;
}
30 changes: 15 additions & 15 deletions packages/@pollyjs/core/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,27 +226,27 @@ export class RouteHandler {
times(n?: number): RouteHandler;
}
export class PollyServer {
timeout: (ms: number) => Promise<void>;
get: (routes?: string | string[]) => RouteHandler;
put: (routes?: string | string[]) => RouteHandler;
post: (routes?: string | string[]) => RouteHandler;
delete: (routes?: string | string[]) => RouteHandler;
patch: (routes?: string | string[]) => RouteHandler;
head: (routes?: string | string[]) => RouteHandler;
options: (routes?: string | string[]) => RouteHandler;
merge: (routes?: string | string[]) => RouteHandler;
any: (routes?: string | string[]) => RouteHandler;
timeout(ms: number): Promise<void>;
get(routes?: string | string[]): RouteHandler;
put(routes?: string | string[]): RouteHandler;
post(routes?: string | string[]): RouteHandler;
delete(routes?: string | string[]): RouteHandler;
patch(routes?: string | string[]): RouteHandler;
head(routes?: string | string[]): RouteHandler;
options(routes?: string | string[]): RouteHandler;
merge(routes?: string | string[]): RouteHandler;
any(routes?: string | string[]): RouteHandler;
host(host: string, callback: () => void): void;
namespace(path: string, callback: () => void): void;
}
export class PollyLogger {
polly: Polly;
log: Logger;
connect: () => void;
disconnect: () => void;
logRequest: (request: Request) => void;
logRequestResponse: (request: Request, response: Response) => void;
logRequestError: (request: Request, error: Error) => void;
connect(): void;
disconnect(): void;
logRequest(request: Request): void;
logRequestResponse(request: Request, response: Response): void;
logRequestError(request: Request, error: Error): void;
}
export type PollyEvent = 'create' | 'stop' | 'register';
export type PollyEventListener = (poll: Polly) => void;
Expand Down
26 changes: 13 additions & 13 deletions packages/@pollyjs/persister/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export interface HarLog {
browser: string;
entries: HarEntry[];
pages: [];
addEntries: (entries: HarEntry[]) => void;
sortEntries: () => void;
addEntries(entries: HarEntry[]): void;
sortEntries(): void;
}

export interface Har {
Expand All @@ -77,15 +77,15 @@ export default class Persister<TOptions extends {} = {}> {
private _cache: Map<string, Har>;
polly: Polly;
hasPending: boolean;
persist: () => Promise<void>;
recordRequest: (request: Request) => void;
private findRecording: (recordingId: string) => Promise<Har | null>;
onFindRecording: (recordingId: string) => Promise<Har | null>;
private saveRecording: (recordingId: string, har: Har) => Promise<void>;
onSaveRecording: (recordingId: string, har: Har) => Promise<void>;
private deleteRecording: (recordingId: string) => Promise<void>;
onDeleteRecording: (recordingId: string) => Promise<void>;
findEntry: (request: Request) => Promise<HarEntry | null>;
stringify: (value: any) => string;
assert: (message: string, condition?: boolean) => void;
persist(): Promise<void>;
recordRequest(request: Request): void;
private findRecording(recordingId: string): Promise<Har | null>;
onFindRecording(recordingId: string): Promise<Har | null>;
private saveRecording(recordingId: string, har: Har): Promise<void>;
onSaveRecording(recordingId: string, har: Har): Promise<void>;
private deleteRecording(recordingId: string): Promise<void>;
onDeleteRecording(recordingId: string): Promise<void>;
findEntry(request: Request): Promise<HarEntry | null>;
stringify(value: any): string;
assert(message: string, condition?: boolean): void;
}

0 comments on commit b88655a

Please sign in to comment.