UNPKG

1.71 kBTypeScriptView Raw
1import { GaxiosOptions, GaxiosResponse } from 'gaxios';
2import { OAuth2Client, GoogleAuth, BaseExternalAccountClient } from 'google-auth-library';
3import { Endpoint } from './endpoint';
4export interface APIRequestParams<T = any> {
5 options: MethodOptions;
6 params: T;
7 requiredParams: string[];
8 pathParams: string[];
9 context: APIRequestContext;
10 mediaUrl?: string | null;
11}
12export interface GoogleConfigurable {
13 _options: GlobalOptions;
14}
15export interface APIRequestContext {
16 google?: GoogleConfigurable;
17 _options: GlobalOptions;
18}
19/**
20 * This interface is a mix of the AxiosRequestConfig options
21 * and our `auth` options.
22 */
23export interface GlobalOptions extends MethodOptions {
24 auth?: GoogleAuth | OAuth2Client | BaseExternalAccountClient | string;
25 universeDomain?: string;
26 universe_domain?: string;
27}
28export interface MethodOptions extends GaxiosOptions {
29 apiVersion?: string;
30 rootUrl?: string;
31 http2?: boolean;
32 userAgentDirectives?: UserAgentDirective[];
33}
34export interface StreamMethodOptions extends MethodOptions {
35 responseType: 'stream';
36}
37/**
38 * An additional directive to add to the user agent header.
39 * Directives come in the form of:
40 * User-Agent: <product> / <product-version> <comment>
41 *
42 * For more information, see:
43 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
44 */
45export interface UserAgentDirective {
46 product: string;
47 version: string;
48 comment?: string;
49}
50export interface ServiceOptions extends GlobalOptions {
51 version?: string;
52}
53export type BodyResponseCallback<T> = (err: Error | null, res?: GaxiosResponse<T> | null) => void;
54export type APIEndpoint = Readonly<Endpoint & any>;