bugzilla
Version:
A NodeJS module to access Bugzilla instances through the REST API.
43 lines (42 loc) • 1.97 kB
TypeScript
import { URLSearchParams, URL } from 'url';
import { AxiosRequestConfig } from 'axios';
import { Validator } from './validators';
export type SearchParams = Record<string, string> | [string, string][] | string | URLSearchParams;
export declare function params(search: SearchParams): URLSearchParams;
/**
* Responsible for requesting data from the bugzilla instance handling any
* necessary authentication and error handling that must happen. The chief
* access is through the `get`, `post` and `put` methods.
*/
export declare abstract class BugzillaLink {
protected readonly instance: URL;
constructor(instance: URL);
protected abstract request<T>(config: AxiosRequestConfig, validator: Validator<T>): Promise<T>;
protected buildURL(path: string, query?: SearchParams): URL;
get<T>(path: string, validator: Validator<T>, searchParams?: SearchParams): Promise<T>;
post<R, T>(path: string, validator: Validator<T>, content: R, searchParams?: SearchParams): Promise<T>;
put<R, T>(path: string, validator: Validator<T>, content: R, searchParams?: SearchParams): Promise<T>;
}
export declare class PublicLink extends BugzillaLink {
protected request<T>(config: AxiosRequestConfig, validator: Validator<T>): Promise<T>;
}
/**
* Handles authentication using an API key.
*/
export declare class ApiKeyLink extends BugzillaLink {
private readonly apiKey;
constructor(instance: URL, apiKey: string);
protected request<T>(config: AxiosRequestConfig, validator: Validator<T>): Promise<T>;
}
/**
* Handles authentication using a username and password.
*/
export declare class PasswordLink extends BugzillaLink {
private readonly username;
private readonly password;
private readonly restrictLogin;
private token;
constructor(instance: URL, username: string, password: string, restrictLogin: boolean);
private login;
protected request<T>(config: AxiosRequestConfig, validator: Validator<T>): Promise<T>;
}