googleapis-common

  • Version 8.0.0
  • Published
  • 76.7 kB
  • 5 dependencies
  • Apache-2.0 license

Install

npm i googleapis-common
yarn add googleapis-common
pnpm add googleapis-common

Overview

A common tooling library used by the googleapis npm module. You probably don't want to use this directly.

Index

Functions

function createAPIRequest

createAPIRequest: {
<T>(parameters: APIRequestParams): Promise<GaxiosResponseWithHTTP2<T>>;
<T>(parameters: APIRequestParams<any>, callback: BodyResponseCallback<T>): void;
};
  • Create and send request to Google API

    Parameter parameters

    Parameters used to form request

    Parameter callback

    Callback when request finished or error found

function getAPI

getAPI: <T>(
api: string,
options: ServiceOptions | string,
versions: { [index: string]: any },
context?: GoogleConfigurable
) => T;

    function headersToClassicHeaders

    headersToClassicHeaders: <T extends Record<string, string>>(
    headers: HeadersInit
    ) => T;
    • A utility for converting potential objects to plain headers objects.

      Parameter headers

      any compatible HeadersInit (Headers, (string, string)[], {})

      Returns

      the headers in Record<string, string> form.

    function marshallGaxiosResponse

    marshallGaxiosResponse: <T extends GaxiosResponse>(
    res?: T
    ) => GaxiosResponseWithHTTP2;
    • marshall a GaxiosResponse into a library-friendly type.

      Parameter res

      the Gaxios Response

      Returns

      the GaxiosResponse with HTTP2-ready/compatible headers

    Classes

    class AuthPlus

    class AuthPlus extends GoogleAuth {}

      property AwsClient

      AwsClient: any;

        property Compute

        Compute: any;

          property ExternalAccountClient

          ExternalAccountClient: any;

            property GoogleAuth

            GoogleAuth: any;

              property IdentityPoolClient

              IdentityPoolClient: any;

                property JWT

                JWT: any;

                  property OAuth2

                  OAuth2: any;

                    method getClient

                    getClient: (
                    options?: GoogleAuthOptions
                    ) => Promise<
                    Compute | JWT | UserRefreshClient | BaseExternalAccountClient | Impersonated
                    >;
                    • Override getClient(), memoizing an instance of auth for subsequent calls to getProjectId().

                    method getProjectId

                    getProjectId: { (): Promise<string>; (callback: ProjectIdCallback): void };
                    • Override getProjectId(), using the most recently configured auth instance when fetching projectId.

                    class Discovery

                    class Discovery {}

                      constructor

                      constructor(options: DiscoveryOptions);
                      • Discovery for discovering API endpoints

                        Parameter options

                        Options for discovery

                      method discoverAllAPIs

                      discoverAllAPIs: (discoveryUrl: string) => Promise<{}>;
                      • Generate all APIs and return as in-memory object.

                        Parameter discoveryUrl

                      method discoverAPI

                      discoverAPI: (
                      apiDiscoveryUrl: string | { url?: string }
                      ) => Promise<EndpointCreator>;
                      • Generate API file given discovery URL

                        Parameter apiDiscoveryUrl

                        URL or filename of discovery doc for API

                        Returns

                        A promise that resolves with a function that creates the endpoint

                      class Endpoint

                      class Endpoint implements Target, APIRequestContext {}

                        constructor

                        constructor(options: {});

                          property google

                          google: any;

                            method applySchema

                            applySchema: (
                            target: Target,
                            rootSchema: Schema,
                            schema: SchemaResource,
                            context: APIRequestContext
                            ) => void;
                            • Given a schema, add methods and resources to a target.

                              Parameter target

                              The target to which to apply the schema.

                              Parameter rootSchema

                              The top-level schema, so we don't lose track of it during recursion.

                              Parameter schema

                              The current schema from which to extract methods and resources.

                              Parameter context

                              The context to add to each method.

                            Interfaces

                            interface APIRequestContext

                            interface APIRequestContext {}

                              property google

                              google?: GoogleConfigurable;

                                interface APIRequestParams

                                interface APIRequestParams<T = any> {}

                                  property context

                                  context: APIRequestContext;

                                    property mediaUrl

                                    mediaUrl?: string | null;

                                      property options

                                      options: MethodOptions;

                                        property params

                                        params: T;

                                          property pathParams

                                          pathParams: string[];

                                            property requiredParams

                                            requiredParams: string[];

                                              interface DiscoveryOptions

                                              interface DiscoveryOptions {}

                                                property debug

                                                debug?: boolean;

                                                  property includePrivate

                                                  includePrivate?: boolean;

                                                    interface FragmentResponse

                                                    interface FragmentResponse {}

                                                      property codeFragment

                                                      codeFragment: {
                                                      [index: string]: {
                                                      fragment: string;
                                                      };
                                                      };

                                                        interface GaxiosResponseWithHTTP2

                                                        interface GaxiosResponseWithHTTP2<T = ReturnType<JSON['parse']>>
                                                        extends Omit<GaxiosResponse<T>, 'headers'> {}
                                                        • Modifiers

                                                          • @experimental

                                                        property headers

                                                        headers: http2.IncomingHttpHeaders & http2.IncomingHttpStatusHeader;

                                                          property request

                                                          request?: http2.ClientHttp2Stream;

                                                            interface GlobalOptions

                                                            interface GlobalOptions extends MethodOptions {}
                                                            • This interface is a mix of the AxiosRequestConfig options and our auth options.

                                                            property auth

                                                            auth?: GoogleAuth | OAuth2Client | BaseExternalAccountClient | string;

                                                              property universe_domain

                                                              universe_domain?: string;

                                                                property universeDomain

                                                                universeDomain?: string;

                                                                  interface GoogleConfigurable

                                                                  interface GoogleConfigurable {}

                                                                    interface MethodOptions

                                                                    interface MethodOptions extends GaxiosOptions {}

                                                                      property apiVersion

                                                                      apiVersion?: string;

                                                                        property http2

                                                                        http2?: boolean;

                                                                          property rootUrl

                                                                          rootUrl?: string;

                                                                            property userAgentDirectives

                                                                            userAgentDirectives?: UserAgentDirective[];

                                                                              interface Schema

                                                                              interface Schema {}

                                                                                property auth

                                                                                auth: {
                                                                                oauth2: {
                                                                                scopes: {
                                                                                [index: string]: {
                                                                                description: string;
                                                                                };
                                                                                };
                                                                                };
                                                                                };

                                                                                  property basePath

                                                                                  basePath: string;

                                                                                    property baseUrl

                                                                                    baseUrl: string;

                                                                                      property batchPath

                                                                                      batchPath: string;

                                                                                        property description

                                                                                        description: string;

                                                                                          property discoveryRestUrl

                                                                                          discoveryRestUrl: string;

                                                                                            property discoveryVersion

                                                                                            discoveryVersion: string;
                                                                                              documentationLink: string;

                                                                                                property etag

                                                                                                etag: string;

                                                                                                  property icons

                                                                                                  icons: {
                                                                                                  x16: string;
                                                                                                  x32: string;
                                                                                                  };

                                                                                                    property id

                                                                                                    id: string;

                                                                                                      property kind

                                                                                                      kind: string;

                                                                                                        property methods

                                                                                                        methods: SchemaMethods;

                                                                                                          property name

                                                                                                          name: string;

                                                                                                            property ownerDomain

                                                                                                            ownerDomain: string;

                                                                                                              property ownerName

                                                                                                              ownerName: string;

                                                                                                                property parameters

                                                                                                                parameters: SchemaParameters;

                                                                                                                  property protocol

                                                                                                                  protocol: string;

                                                                                                                    property resources

                                                                                                                    resources: SchemaResources;

                                                                                                                      property revision

                                                                                                                      revision: string;

                                                                                                                        property rootUrl

                                                                                                                        rootUrl: string;

                                                                                                                          property schemas

                                                                                                                          schemas: SchemaItems;

                                                                                                                            property servicePath

                                                                                                                            servicePath: string;

                                                                                                                              property title

                                                                                                                              title: string;

                                                                                                                                property version

                                                                                                                                version: string;

                                                                                                                                  interface SchemaItem

                                                                                                                                  interface SchemaItem {}

                                                                                                                                    property $ref

                                                                                                                                    $ref?: string;

                                                                                                                                      property additionalProperties

                                                                                                                                      additionalProperties?: {
                                                                                                                                      [index: string]: SchemaItem;
                                                                                                                                      };

                                                                                                                                        property default

                                                                                                                                        default?: string;

                                                                                                                                          property description

                                                                                                                                          description?: string;

                                                                                                                                            property format

                                                                                                                                            format?: ParameterFormat;

                                                                                                                                              property id

                                                                                                                                              id?: string;

                                                                                                                                                property items

                                                                                                                                                items?: {
                                                                                                                                                [index: string]: SchemaItem;
                                                                                                                                                };

                                                                                                                                                  property properties

                                                                                                                                                  properties?: {
                                                                                                                                                  [index: string]: SchemaItem;
                                                                                                                                                  };

                                                                                                                                                    property type

                                                                                                                                                    type?: SchemaType;

                                                                                                                                                      interface SchemaItems

                                                                                                                                                      interface SchemaItems {}

                                                                                                                                                        index signature

                                                                                                                                                        [index: string]: SchemaItem;

                                                                                                                                                          interface SchemaMethod

                                                                                                                                                          interface SchemaMethod {}

                                                                                                                                                            property apiVersion

                                                                                                                                                            apiVersion?: string;

                                                                                                                                                              property description

                                                                                                                                                              description: string;

                                                                                                                                                                property fragment

                                                                                                                                                                fragment: string;

                                                                                                                                                                  property httpMethod

                                                                                                                                                                  httpMethod: HttpMethod;

                                                                                                                                                                    property id

                                                                                                                                                                    id: string;

                                                                                                                                                                      property mediaUpload

                                                                                                                                                                      mediaUpload: {
                                                                                                                                                                      protocols: {
                                                                                                                                                                      simple: {
                                                                                                                                                                      path: string;
                                                                                                                                                                      };
                                                                                                                                                                      };
                                                                                                                                                                      };

                                                                                                                                                                        property parameterOrder

                                                                                                                                                                        parameterOrder?: string[];

                                                                                                                                                                          property parameters

                                                                                                                                                                          parameters?: {
                                                                                                                                                                          [index: string]: SchemaParameter;
                                                                                                                                                                          };

                                                                                                                                                                            property path

                                                                                                                                                                            path: string;

                                                                                                                                                                              property request

                                                                                                                                                                              request: {
                                                                                                                                                                              $ref: string;
                                                                                                                                                                              };

                                                                                                                                                                                property response

                                                                                                                                                                                response: {
                                                                                                                                                                                $ref: string;
                                                                                                                                                                                };

                                                                                                                                                                                  property sampleUrl

                                                                                                                                                                                  sampleUrl: string;

                                                                                                                                                                                    property scopes

                                                                                                                                                                                    scopes: string[];

                                                                                                                                                                                      property supportsMediaDownload

                                                                                                                                                                                      supportsMediaDownload?: boolean;

                                                                                                                                                                                        interface SchemaMethods

                                                                                                                                                                                        interface SchemaMethods {}

                                                                                                                                                                                          index signature

                                                                                                                                                                                          [index: string]: SchemaMethod;

                                                                                                                                                                                            interface SchemaParameter

                                                                                                                                                                                            interface SchemaParameter {}

                                                                                                                                                                                              property default

                                                                                                                                                                                              default: string;

                                                                                                                                                                                                property description

                                                                                                                                                                                                description: string;

                                                                                                                                                                                                  property enum

                                                                                                                                                                                                  enum: string[];

                                                                                                                                                                                                    property enumDescription

                                                                                                                                                                                                    enumDescription: string[];

                                                                                                                                                                                                      property format

                                                                                                                                                                                                      format: ParameterFormat;

                                                                                                                                                                                                        property location

                                                                                                                                                                                                        location: string;

                                                                                                                                                                                                          property required

                                                                                                                                                                                                          required: boolean;

                                                                                                                                                                                                            property type

                                                                                                                                                                                                            type: SchemaType;

                                                                                                                                                                                                              interface SchemaParameters

                                                                                                                                                                                                              interface SchemaParameters {}

                                                                                                                                                                                                                index signature

                                                                                                                                                                                                                [index: string]: SchemaParameter;

                                                                                                                                                                                                                  interface SchemaResource

                                                                                                                                                                                                                  interface SchemaResource {}

                                                                                                                                                                                                                    property methods

                                                                                                                                                                                                                    methods?: SchemaMethods;

                                                                                                                                                                                                                      property resources

                                                                                                                                                                                                                      resources?: SchemaResources;

                                                                                                                                                                                                                        interface SchemaResources

                                                                                                                                                                                                                        interface SchemaResources {}

                                                                                                                                                                                                                          index signature

                                                                                                                                                                                                                          [index: string]: SchemaResource;

                                                                                                                                                                                                                            interface Schemas

                                                                                                                                                                                                                            interface Schemas {}
                                                                                                                                                                                                                            • These are a collection of interfaces that represent the GoogleApis Discovery json formats.

                                                                                                                                                                                                                            property discoveryVersion

                                                                                                                                                                                                                            discoveryVersion: string;

                                                                                                                                                                                                                              property items

                                                                                                                                                                                                                              items: Schema[];

                                                                                                                                                                                                                                property kind

                                                                                                                                                                                                                                kind: string;

                                                                                                                                                                                                                                  interface ServiceOptions

                                                                                                                                                                                                                                  interface ServiceOptions extends GlobalOptions {}

                                                                                                                                                                                                                                    property version

                                                                                                                                                                                                                                    version?: string;

                                                                                                                                                                                                                                      interface StreamMethodOptions

                                                                                                                                                                                                                                      interface StreamMethodOptions extends MethodOptions {}

                                                                                                                                                                                                                                        property responseType

                                                                                                                                                                                                                                        responseType: 'stream';

                                                                                                                                                                                                                                          interface Target

                                                                                                                                                                                                                                          interface Target {}

                                                                                                                                                                                                                                            index signature

                                                                                                                                                                                                                                            [index: string]: {};

                                                                                                                                                                                                                                              Type Aliases

                                                                                                                                                                                                                                              type APIEndpoint

                                                                                                                                                                                                                                              type APIEndpoint = Readonly<Endpoint & any>;

                                                                                                                                                                                                                                                type BodyResponseCallback

                                                                                                                                                                                                                                                type BodyResponseCallback<T> = (
                                                                                                                                                                                                                                                err: Error | null,
                                                                                                                                                                                                                                                res?: GaxiosResponseWithHTTP2<T> | null
                                                                                                                                                                                                                                                ) => void;

                                                                                                                                                                                                                                                  type EndpointCreator

                                                                                                                                                                                                                                                  type EndpointCreator = (options: GlobalOptions, google: {}) => Endpoint;

                                                                                                                                                                                                                                                    type HeadersInit

                                                                                                                                                                                                                                                    type HeadersInit = ConstructorParameters<typeof Headers>[0];

                                                                                                                                                                                                                                                      type HttpMethod

                                                                                                                                                                                                                                                      type HttpMethod = 'GET' | 'PATCH' | 'PUT';

                                                                                                                                                                                                                                                        type ParameterFormat

                                                                                                                                                                                                                                                        type ParameterFormat = 'int32';

                                                                                                                                                                                                                                                          type SchemaType

                                                                                                                                                                                                                                                          type SchemaType = 'object' | 'integer' | 'string' | 'array' | 'boolean';

                                                                                                                                                                                                                                                            Package Files (10)

                                                                                                                                                                                                                                                            Dependencies (5)

                                                                                                                                                                                                                                                            Dev Dependencies (42)

                                                                                                                                                                                                                                                            Peer Dependencies (0)

                                                                                                                                                                                                                                                            No peer dependencies.

                                                                                                                                                                                                                                                            Badge

                                                                                                                                                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/googleapis-common.

                                                                                                                                                                                                                                                            • Markdown
                                                                                                                                                                                                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/googleapis-common)
                                                                                                                                                                                                                                                            • HTML
                                                                                                                                                                                                                                                              <a href="https://www.jsdocs.io/package/googleapis-common"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>