mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-11 11:50:54 +08:00
Add definition for custom interceptors
This commit is contained in:
Vendored
+33
@@ -59,9 +59,42 @@ declare module "rest" {
|
||||
skip(): Client;
|
||||
wrap(interceptor: Interceptor, config?: any): Client;
|
||||
}
|
||||
|
||||
export interface Meta {
|
||||
client: Client;
|
||||
arguments: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "rest/interceptor" {
|
||||
import when = require("when");
|
||||
import rest = require("rest");
|
||||
|
||||
// TODO: These two configs should be merged to use union output types.
|
||||
|
||||
interface Config {
|
||||
init?: (config: any) => any;
|
||||
request?: (request: rest.Request, config: any, meta: rest.Meta) => rest.Request;
|
||||
response?: (response: rest.Response, config: any, meta: rest.Meta) => rest.Response;
|
||||
success?: (response: rest.Response, config: any, meta: rest.Meta) => rest.Response;
|
||||
error?: (response: rest.Response, config: any, meta: rest.Meta) => rest.Response;
|
||||
}
|
||||
|
||||
interface PromiseConfig {
|
||||
init?: (config: any) => any;
|
||||
request?: (request: rest.Request, config: any, meta: rest.Meta) => when.Promise<rest.Request>;
|
||||
response?: (response: rest.Response, config: any, meta: rest.Meta) => when.Promise<rest.Response>;
|
||||
success?: (response: rest.Response, config: any, meta: rest.Meta) => when.Promise<rest.Response>;
|
||||
error?: (response: rest.Response, config: any, meta: rest.Meta) => when.Promise<rest.Response>;
|
||||
}
|
||||
|
||||
function interceptor(config: Config): rest.Interceptor;
|
||||
function interceptor(config: PromiseConfig): rest.Interceptor;
|
||||
|
||||
export = interceptor;
|
||||
}
|
||||
|
||||
declare module "rest/interceptor/defaultRequest" {
|
||||
import rest = require("rest");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user