Updating NPM dependencies
This commit is contained in:
10
node_modules/googleapis-common/build/src/api.d.ts
generated
vendored
10
node_modules/googleapis-common/build/src/api.d.ts
generated
vendored
@@ -1,5 +1,5 @@
|
||||
import { GaxiosOptions, GaxiosResponse } from 'gaxios';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import { OAuth2Client, GoogleAuth } from 'google-auth-library';
|
||||
import { Endpoint } from './endpoint';
|
||||
export interface APIRequestParams<T = any> {
|
||||
options: MethodOptions;
|
||||
@@ -18,15 +18,19 @@ export interface APIRequestContext {
|
||||
}
|
||||
/**
|
||||
* This interface is a mix of the AxiosRequestConfig options
|
||||
* and our `auth: OAuth2Client|string` options.
|
||||
* and our `auth` options.
|
||||
*/
|
||||
export interface GlobalOptions extends MethodOptions {
|
||||
auth?: OAuth2Client | string;
|
||||
auth?: GoogleAuth | OAuth2Client | string;
|
||||
}
|
||||
export interface MethodOptions extends GaxiosOptions {
|
||||
rootUrl?: string;
|
||||
http2?: boolean;
|
||||
userAgentDirectives?: UserAgentDirective[];
|
||||
}
|
||||
export interface StreamMethodOptions extends MethodOptions {
|
||||
responseType: 'stream';
|
||||
}
|
||||
/**
|
||||
* An additional directive to add to the user agent header.
|
||||
* Directives come in the form of:
|
||||
|
||||
2
node_modules/googleapis-common/build/src/api.js
generated
vendored
2
node_modules/googleapis-common/build/src/api.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright 2018, Google, LLC.
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
5
node_modules/googleapis-common/build/src/apiIndex.js
generated
vendored
5
node_modules/googleapis-common/build/src/apiIndex.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright 2018, Google, LLC.
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@@ -12,8 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAPI = void 0;
|
||||
function getAPI(api, options,
|
||||
// tslint:disable-next-line no-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
versions, context) {
|
||||
let version;
|
||||
if (typeof options === 'string') {
|
||||
|
||||
15
node_modules/googleapis-common/build/src/apirequest.d.ts
generated
vendored
15
node_modules/googleapis-common/build/src/apirequest.d.ts
generated
vendored
@@ -1,18 +1,3 @@
|
||||
/**
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { GaxiosPromise } from 'gaxios';
|
||||
import { APIRequestParams, BodyResponseCallback } from './api';
|
||||
/**
|
||||
|
||||
218
node_modules/googleapis-common/build/src/apirequest.js
generated
vendored
218
node_modules/googleapis-common/build/src/apirequest.js
generated
vendored
@@ -1,20 +1,18 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createAPIRequest = void 0;
|
||||
const google_auth_library_1 = require("google-auth-library");
|
||||
const qs = require("qs");
|
||||
const stream = require("stream");
|
||||
@@ -22,10 +20,18 @@ const urlTemplate = require("url-template");
|
||||
const uuid = require("uuid");
|
||||
const extend = require("extend");
|
||||
const isbrowser_1 = require("./isbrowser");
|
||||
// tslint:disable-next-line no-var-requires
|
||||
const h2 = require("./http2");
|
||||
const resolve = require("url");
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const pkg = require('../../package.json');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function isReadableStream(obj) {
|
||||
return obj instanceof stream.Readable && typeof obj._read === 'function';
|
||||
return (obj !== null &&
|
||||
typeof obj === 'object' &&
|
||||
typeof obj.pipe === 'function' &&
|
||||
obj.readable !== false &&
|
||||
typeof obj._read === 'function' &&
|
||||
typeof obj._readableState === 'object');
|
||||
}
|
||||
function getMissingParams(params, required) {
|
||||
const missing = new Array();
|
||||
@@ -49,21 +55,20 @@ function createAPIRequest(parameters, callback) {
|
||||
}
|
||||
exports.createAPIRequest = createAPIRequest;
|
||||
async function createAPIRequestAsync(parameters) {
|
||||
let params = parameters.params;
|
||||
const options = Object.assign({}, parameters.options);
|
||||
// Create a new params object so it can no longer be modified from outside
|
||||
// code Also support global and per-client params, but allow them to be
|
||||
// overriden per-request
|
||||
const topOptions = parameters.context.google &&
|
||||
parameters.context.google._options &&
|
||||
parameters.context.google._options.params
|
||||
? parameters.context.google._options.params
|
||||
: {};
|
||||
params = Object.assign({}, // New base object
|
||||
topOptions, // Global params
|
||||
parameters.context._options.params, // Per-client params
|
||||
params // API call params
|
||||
var _a;
|
||||
// Combine the GaxiosOptions options passed with this specific
|
||||
// API call with the global options configured at the API Context
|
||||
// level, or at the global level.
|
||||
const options = extend(true, {}, // Ensure we don't leak settings upstream
|
||||
((_a = parameters.context.google) === null || _a === void 0 ? void 0 : _a._options) || {}, // Google level options
|
||||
parameters.context._options || {}, // Per-API options
|
||||
parameters.options // API call params
|
||||
);
|
||||
const params = extend(true, {}, // New base object
|
||||
options.params, // Combined global/per-api params
|
||||
parameters.params // API call params
|
||||
);
|
||||
options.userAgentDirectives = options.userAgentDirectives || [];
|
||||
const media = params.media || {};
|
||||
/**
|
||||
* In a previous version of this API, the request body was stuffed in a field
|
||||
@@ -88,11 +93,7 @@ async function createAPIRequestAsync(parameters) {
|
||||
delete params.resource;
|
||||
}
|
||||
delete params.requestBody;
|
||||
let authClient = params.auth ||
|
||||
parameters.context._options.auth ||
|
||||
(parameters.context.google
|
||||
? parameters.context.google._options.auth
|
||||
: null);
|
||||
let authClient = params.auth || options.auth;
|
||||
const defaultMime = typeof media.body === 'string' ? 'text/plain' : 'application/octet-stream';
|
||||
delete params.media;
|
||||
delete params.auth;
|
||||
@@ -122,6 +123,12 @@ async function createAPIRequestAsync(parameters) {
|
||||
if (parameters.mediaUrl) {
|
||||
parameters.mediaUrl = urlTemplate.parse(parameters.mediaUrl).expand(params);
|
||||
}
|
||||
// Rewrite url if rootUrl is globally set
|
||||
if (parameters.context._options.rootUrl !== undefined &&
|
||||
options.url !== undefined) {
|
||||
const path = options.url.slice(parameters.context._options.rootUrl.length);
|
||||
options.url = resolve.resolve(parameters.context._options.rootUrl, path);
|
||||
}
|
||||
// When forming the querystring, override the serializer so that array
|
||||
// values are serialized like this:
|
||||
// myParams: ['one', 'two'] ---> 'myParams=one&myParams=two'
|
||||
@@ -130,74 +137,90 @@ async function createAPIRequestAsync(parameters) {
|
||||
options.paramsSerializer = params => {
|
||||
return qs.stringify(params, { arrayFormat: 'repeat' });
|
||||
};
|
||||
// delete path parameters from the params object so they do not end up in
|
||||
// query
|
||||
parameters.pathParams.forEach(param => {
|
||||
delete params[param];
|
||||
if (parameters.context &&
|
||||
parameters.context._options &&
|
||||
parameters.context._options.params) {
|
||||
delete parameters.context._options.params[param];
|
||||
}
|
||||
});
|
||||
// delete path params from the params object so they do not end up in query
|
||||
parameters.pathParams.forEach(param => delete params[param]);
|
||||
// if authClient is actually a string, use it as an API KEY
|
||||
if (typeof authClient === 'string') {
|
||||
params.key = params.key || authClient;
|
||||
authClient = undefined;
|
||||
}
|
||||
function multipartUpload(multipart) {
|
||||
const boundary = uuid.v4();
|
||||
const finale = `--${boundary}--`;
|
||||
const rStream = new stream.PassThrough({
|
||||
flush(callback) {
|
||||
this.push('\r\n');
|
||||
this.push(finale);
|
||||
callback();
|
||||
},
|
||||
});
|
||||
const pStream = new ProgressStream();
|
||||
const isStream = isReadableStream(multipart[1].body);
|
||||
headers['content-type'] = `multipart/related; boundary=${boundary}`;
|
||||
for (const part of multipart) {
|
||||
const preamble = `--${boundary}\r\ncontent-type: ${part['content-type']}\r\n\r\n`;
|
||||
rStream.push(preamble);
|
||||
if (typeof part.body === 'string') {
|
||||
rStream.push(part.body);
|
||||
rStream.push('\r\n');
|
||||
}
|
||||
else {
|
||||
// Gaxios does not natively support onUploadProgress in node.js.
|
||||
// Pipe through the pStream first to read the number of bytes read
|
||||
// for the purpose of tracking progress.
|
||||
pStream.on('progress', bytesRead => {
|
||||
if (options.onUploadProgress) {
|
||||
options.onUploadProgress({ bytesRead });
|
||||
}
|
||||
});
|
||||
part.body.pipe(pStream).pipe(rStream);
|
||||
}
|
||||
}
|
||||
if (!isStream) {
|
||||
rStream.push(finale);
|
||||
rStream.push(null);
|
||||
}
|
||||
options.data = rStream;
|
||||
}
|
||||
function browserMultipartUpload(multipart) {
|
||||
const boundary = uuid.v4();
|
||||
const finale = `--${boundary}--`;
|
||||
headers['content-type'] = `multipart/related; boundary=${boundary}`;
|
||||
let content = '';
|
||||
for (const part of multipart) {
|
||||
const preamble = `--${boundary}\r\ncontent-type: ${part['content-type']}\r\n\r\n`;
|
||||
content += preamble;
|
||||
if (typeof part.body === 'string') {
|
||||
content += part.body;
|
||||
content += '\r\n';
|
||||
}
|
||||
}
|
||||
content += finale;
|
||||
options.data = content;
|
||||
}
|
||||
if (parameters.mediaUrl && media.body) {
|
||||
options.url = parameters.mediaUrl;
|
||||
if (resource) {
|
||||
// gaxios doesn't support multipart/related uploads, so it has to
|
||||
// be implemented here.
|
||||
params.uploadType = 'multipart';
|
||||
const multipart = [
|
||||
{ 'Content-Type': 'application/json', body: JSON.stringify(resource) },
|
||||
{ 'content-type': 'application/json', body: JSON.stringify(resource) },
|
||||
{
|
||||
'Content-Type': media.mimeType || (resource && resource.mimeType) || defaultMime,
|
||||
'content-type': media.mimeType || (resource && resource.mimeType) || defaultMime,
|
||||
body: media.body,
|
||||
},
|
||||
];
|
||||
const boundary = uuid.v4();
|
||||
const finale = `--${boundary}--`;
|
||||
const rStream = new stream.PassThrough({
|
||||
flush(callback) {
|
||||
this.push('\r\n');
|
||||
this.push(finale);
|
||||
callback();
|
||||
},
|
||||
});
|
||||
const pStream = new ProgressStream();
|
||||
const isStream = isReadableStream(multipart[1].body);
|
||||
headers['Content-Type'] = `multipart/related; boundary=${boundary}`;
|
||||
for (const part of multipart) {
|
||||
const preamble = `--${boundary}\r\nContent-Type: ${part['Content-Type']}\r\n\r\n`;
|
||||
rStream.push(preamble);
|
||||
if (typeof part.body === 'string') {
|
||||
rStream.push(part.body);
|
||||
rStream.push('\r\n');
|
||||
}
|
||||
else {
|
||||
// Gaxios does not natively support onUploadProgress in node.js.
|
||||
// Pipe through the pStream first to read the number of bytes read
|
||||
// for the purpose of tracking progress.
|
||||
pStream.on('progress', bytesRead => {
|
||||
if (options.onUploadProgress) {
|
||||
options.onUploadProgress({ bytesRead });
|
||||
}
|
||||
});
|
||||
part.body.pipe(pStream).pipe(rStream);
|
||||
}
|
||||
if (!isbrowser_1.isBrowser()) {
|
||||
// gaxios doesn't support multipart/related uploads, so it has to
|
||||
// be implemented here.
|
||||
multipartUpload(multipart);
|
||||
}
|
||||
if (!isStream) {
|
||||
rStream.push(finale);
|
||||
rStream.push(null);
|
||||
else {
|
||||
browserMultipartUpload(multipart);
|
||||
}
|
||||
options.data = rStream;
|
||||
}
|
||||
else {
|
||||
params.uploadType = 'media';
|
||||
Object.assign(headers, { 'Content-Type': media.mimeType || defaultMime });
|
||||
Object.assign(headers, { 'content-type': media.mimeType || defaultMime });
|
||||
options.data = media.body;
|
||||
}
|
||||
}
|
||||
@@ -208,13 +231,12 @@ async function createAPIRequestAsync(parameters) {
|
||||
options.params = params;
|
||||
if (!isbrowser_1.isBrowser()) {
|
||||
options.headers['Accept-Encoding'] = 'gzip';
|
||||
const directives = options.userAgentDirectives || [];
|
||||
directives.push({
|
||||
options.userAgentDirectives.push({
|
||||
product: 'google-api-nodejs-client',
|
||||
version: pkg.version,
|
||||
comment: 'gzip',
|
||||
});
|
||||
const userAgent = directives
|
||||
const userAgent = options.userAgentDirectives
|
||||
.map(d => {
|
||||
let line = `${d.product}/${d.version}`;
|
||||
if (d.comment) {
|
||||
@@ -235,20 +257,24 @@ async function createAPIRequestAsync(parameters) {
|
||||
}
|
||||
// Retry by default
|
||||
options.retry = options.retry === undefined ? true : options.retry;
|
||||
// Combine the GaxiosOptions options passed with this specific
|
||||
// API call witht the global options configured at the API Context
|
||||
// level, or at the global level.
|
||||
const mergedOptions = extend(true, {}, parameters.context.google ? parameters.context.google._options : {}, parameters.context._options, options);
|
||||
delete mergedOptions.auth; // is overridden by our auth code
|
||||
delete options.auth; // is overridden by our auth code
|
||||
// Perform the HTTP request. NOTE: this function used to return a
|
||||
// mikeal/request object. Since the transition to Axios, the method is
|
||||
// now void. This may be a source of confusion for users upgrading from
|
||||
// version 24.0 -> 25.0 or up.
|
||||
if (authClient && typeof authClient === 'object') {
|
||||
return authClient.request(mergedOptions);
|
||||
if (options.http2) {
|
||||
const authHeaders = await authClient.getRequestHeaders(options.url);
|
||||
const mooOpts = Object.assign({}, options);
|
||||
mooOpts.headers = Object.assign(mooOpts.headers, authHeaders);
|
||||
return h2.request(mooOpts);
|
||||
}
|
||||
else {
|
||||
return authClient.request(options);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return new google_auth_library_1.DefaultTransporter().request(mergedOptions);
|
||||
return new google_auth_library_1.DefaultTransporter().request(options);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -260,7 +286,7 @@ class ProgressStream extends stream.Transform {
|
||||
super(...arguments);
|
||||
this.bytesRead = 0;
|
||||
}
|
||||
// tslint:disable-next-line: no-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
_transform(chunk, encoding, callback) {
|
||||
this.bytesRead += chunk.length;
|
||||
this.emit('progress', this.bytesRead);
|
||||
|
||||
7
node_modules/googleapis-common/build/src/authplus.js
generated
vendored
7
node_modules/googleapis-common/build/src/authplus.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright 2019 Google LLC
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@@ -12,17 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthPlus = void 0;
|
||||
const google_auth_library_1 = require("google-auth-library");
|
||||
class AuthPlus extends google_auth_library_1.GoogleAuth {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// tslint:disable-next-line: variable-name
|
||||
this.JWT = google_auth_library_1.JWT;
|
||||
// tslint:disable-next-line: variable-name
|
||||
this.Compute = google_auth_library_1.Compute;
|
||||
// tslint:disable-next-line: variable-name
|
||||
this.OAuth2 = google_auth_library_1.OAuth2Client;
|
||||
// tslint:disable-next-line: variable-name
|
||||
this.GoogleAuth = google_auth_library_1.GoogleAuth;
|
||||
}
|
||||
/**
|
||||
|
||||
13
node_modules/googleapis-common/build/src/discovery.js
generated
vendored
13
node_modules/googleapis-common/build/src/discovery.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright 2014-2016, Google, Inc.
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@@ -12,9 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Discovery = void 0;
|
||||
const fs = require("fs");
|
||||
const google_auth_library_1 = require("google-auth-library");
|
||||
const url = require("url");
|
||||
const resolve = require("url");
|
||||
const util = require("util");
|
||||
const apirequest_1 = require("./apirequest");
|
||||
const endpoint_1 = require("./endpoint");
|
||||
@@ -68,7 +69,7 @@ class Discovery {
|
||||
return { api, endpointCreator };
|
||||
}));
|
||||
const versionIndex = {};
|
||||
// tslint:disable-next-line no-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const apisIndex = {};
|
||||
for (const set of apis) {
|
||||
if (!apisIndex[set.api.name]) {
|
||||
@@ -88,9 +89,7 @@ class Discovery {
|
||||
throw new Error('Argument error: Accepts only string or object');
|
||||
}
|
||||
try {
|
||||
const ep =
|
||||
// tslint:disable-next-line: no-any
|
||||
set.endpointCreator(options, this);
|
||||
const ep = set.endpointCreator(options, this);
|
||||
return Object.freeze(ep); // create new & freeze
|
||||
}
|
||||
catch (e) {
|
||||
@@ -110,7 +109,7 @@ class Discovery {
|
||||
*/
|
||||
async discoverAPI(apiDiscoveryUrl) {
|
||||
if (typeof apiDiscoveryUrl === 'string') {
|
||||
const parts = url.parse(apiDiscoveryUrl);
|
||||
const parts = resolve.parse(apiDiscoveryUrl);
|
||||
if (apiDiscoveryUrl && !parts.protocol) {
|
||||
this.log('Reading from file ' + apiDiscoveryUrl);
|
||||
const file = await readFile(apiDiscoveryUrl, { encoding: 'utf8' });
|
||||
|
||||
7
node_modules/googleapis-common/build/src/endpoint.js
generated
vendored
7
node_modules/googleapis-common/build/src/endpoint.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright 2018, Google, LLC.
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Endpoint = void 0;
|
||||
const apirequest_1 = require("./apirequest");
|
||||
class Endpoint {
|
||||
constructor(options) {
|
||||
@@ -31,7 +32,7 @@ class Endpoint {
|
||||
this.applyMethodsFromSchema(target, rootSchema, schema, context);
|
||||
if (schema.resources) {
|
||||
for (const resourceName in schema.resources) {
|
||||
if (schema.resources.hasOwnProperty(resourceName)) {
|
||||
if (Object.prototype.hasOwnProperty.call(schema.resources, resourceName)) {
|
||||
const resource = schema.resources[resourceName];
|
||||
if (!target[resourceName]) {
|
||||
target[resourceName] = {};
|
||||
@@ -53,7 +54,7 @@ class Endpoint {
|
||||
applyMethodsFromSchema(target, rootSchema, schema, context) {
|
||||
if (schema.methods) {
|
||||
for (const name in schema.methods) {
|
||||
if (schema.methods.hasOwnProperty(name)) {
|
||||
if (Object.prototype.hasOwnProperty.call(schema.methods, name)) {
|
||||
const method = schema.methods[name];
|
||||
target[name] = this.makeMethod(rootSchema, method, context);
|
||||
}
|
||||
|
||||
25
node_modules/googleapis-common/build/src/http2.d.ts
generated
vendored
Normal file
25
node_modules/googleapis-common/build/src/http2.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/// <reference types="node" />
|
||||
import * as http2 from 'http2';
|
||||
import { URL } from 'url';
|
||||
import { GaxiosResponse, GaxiosOptions } from 'gaxios';
|
||||
/**
|
||||
* Reference to the ClientHttp2Session and a timeout handler.
|
||||
* @private
|
||||
*/
|
||||
export interface SessionData {
|
||||
session: http2.ClientHttp2Session;
|
||||
timeoutHandle?: NodeJS.Timer;
|
||||
}
|
||||
/**
|
||||
* List of sessions current in use.
|
||||
* @private
|
||||
*/
|
||||
export declare const sessions: {
|
||||
[index: string]: SessionData;
|
||||
};
|
||||
/**
|
||||
* Public method to make an http2 request.
|
||||
* @param config - Request options.
|
||||
*/
|
||||
export declare function request<T>(config: GaxiosOptions): Promise<GaxiosResponse<T>>;
|
||||
export declare function closeSession(url: URL): Promise<void>;
|
||||
250
node_modules/googleapis-common/build/src/http2.js
generated
vendored
Normal file
250
node_modules/googleapis-common/build/src/http2.js
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
"use strict";
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.closeSession = exports.request = exports.sessions = void 0;
|
||||
const http2 = require("http2");
|
||||
const zlib = require("zlib");
|
||||
const url_1 = require("url");
|
||||
const qs = require("qs");
|
||||
const extend = require("extend");
|
||||
const stream_1 = require("stream");
|
||||
const util = require("util");
|
||||
const process = require("process");
|
||||
const common_1 = require("gaxios/build/src/common");
|
||||
const { HTTP2_HEADER_CONTENT_ENCODING, HTTP2_HEADER_CONTENT_TYPE, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS, } = http2.constants;
|
||||
const DEBUG = !!process.env.HTTP2_DEBUG;
|
||||
/**
|
||||
* List of sessions current in use.
|
||||
* @private
|
||||
*/
|
||||
exports.sessions = {};
|
||||
let warned = false;
|
||||
/**
|
||||
* Public method to make an http2 request.
|
||||
* @param config - Request options.
|
||||
*/
|
||||
async function request(config) {
|
||||
// Make sure users know this API is unstable
|
||||
if (!warned) {
|
||||
const message = `
|
||||
The HTTP/2 API in googleapis is unstable! This is an early implementation
|
||||
that should not be used in production. It may change in unpredictable
|
||||
ways. Please only use this for experimentation.
|
||||
`;
|
||||
process.emitWarning(message, 'GOOG_HTTP2');
|
||||
warned = true;
|
||||
}
|
||||
const opts = extend(true, {}, config);
|
||||
opts.validateStatus = opts.validateStatus || validateStatus;
|
||||
opts.responseType = opts.responseType || 'json';
|
||||
const url = new url_1.URL(opts.url);
|
||||
// Check for an existing session to this host, or go create a new one.
|
||||
const sessionData = _getClient(url.host);
|
||||
// Since we're using this session, clear the timeout handle to ensure
|
||||
// it stays in memory and connected for a while further.
|
||||
if (sessionData.timeoutHandle !== undefined) {
|
||||
clearTimeout(sessionData.timeoutHandle);
|
||||
}
|
||||
// Assemble the querystring based on config.params. We're using the
|
||||
// `qs` module to make life a little easier.
|
||||
let pathWithQs = url.pathname;
|
||||
if (config.params && Object.keys(config.params).length > 0) {
|
||||
const q = qs.stringify(opts.params);
|
||||
pathWithQs += `?${q}`;
|
||||
}
|
||||
// Assemble the headers based on basic HTTP2 primitives (path, method) and
|
||||
// custom headers sent from the consumer. Note: I am using `Object.assign`
|
||||
// here making the assumption these objects are not deep. If it turns out
|
||||
// they are, we may need to use the `extend` npm module for deep cloning.
|
||||
const headers = Object.assign({}, opts.headers, {
|
||||
[HTTP2_HEADER_PATH]: pathWithQs,
|
||||
[HTTP2_HEADER_METHOD]: config.method || 'GET',
|
||||
});
|
||||
// NOTE: This is working around an upstream bug in `apirequest.ts`. The
|
||||
// request path assumes that the `content-type` header is going to be set in
|
||||
// the underlying HTTP Client. This hack provides bug for bug compatability
|
||||
// with this bug in gaxios:
|
||||
// https://github.com/googleapis/gaxios/blob/master/src/gaxios.ts#L202
|
||||
if (!headers[HTTP2_HEADER_CONTENT_TYPE]) {
|
||||
if (opts.responseType !== 'text') {
|
||||
headers[HTTP2_HEADER_CONTENT_TYPE] = 'application/json';
|
||||
}
|
||||
}
|
||||
const res = {
|
||||
config,
|
||||
request: {},
|
||||
headers: [],
|
||||
status: 0,
|
||||
data: {},
|
||||
statusText: '',
|
||||
};
|
||||
const chunks = [];
|
||||
const session = sessionData.session;
|
||||
let req;
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
req = session
|
||||
.request(headers)
|
||||
.on('response', headers => {
|
||||
res.headers = headers;
|
||||
res.status = Number(headers[HTTP2_HEADER_STATUS]);
|
||||
let stream = req;
|
||||
if (headers[HTTP2_HEADER_CONTENT_ENCODING] === 'gzip') {
|
||||
stream = req.pipe(zlib.createGunzip());
|
||||
}
|
||||
if (opts.responseType === 'stream') {
|
||||
res.data = stream;
|
||||
resolve(res);
|
||||
return;
|
||||
}
|
||||
stream
|
||||
.on('data', d => {
|
||||
chunks.push(d);
|
||||
})
|
||||
.on('error', err => {
|
||||
reject(err);
|
||||
return;
|
||||
})
|
||||
.on('end', () => {
|
||||
const buf = Buffer.concat(chunks);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let data = buf;
|
||||
if (buf) {
|
||||
if (opts.responseType === 'json') {
|
||||
try {
|
||||
data = JSON.parse(buf.toString('utf8'));
|
||||
}
|
||||
catch (_a) {
|
||||
data = buf.toString('utf8');
|
||||
}
|
||||
}
|
||||
else if (opts.responseType === 'text') {
|
||||
data = buf.toString('utf8');
|
||||
}
|
||||
else if (opts.responseType === 'arraybuffer') {
|
||||
data = buf.buffer;
|
||||
}
|
||||
res.data = data;
|
||||
}
|
||||
if (!opts.validateStatus(res.status)) {
|
||||
let message = `Request failed with status code ${res.status}. `;
|
||||
if (res.data && typeof res.data === 'object') {
|
||||
const body = util.inspect(res.data, { depth: 5 });
|
||||
message = `${message}\n'${body}`;
|
||||
}
|
||||
reject(new common_1.GaxiosError(message, opts, res));
|
||||
}
|
||||
resolve(res);
|
||||
return;
|
||||
});
|
||||
})
|
||||
.on('error', e => {
|
||||
reject(e);
|
||||
return;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
closeSession(url);
|
||||
reject(e);
|
||||
}
|
||||
res.request = req;
|
||||
// If data was provided, write it to the request in the form of
|
||||
// a stream, string data, or a basic object.
|
||||
if (config.data) {
|
||||
if (config.data instanceof stream_1.Stream) {
|
||||
config.data.pipe(req);
|
||||
}
|
||||
else if (typeof config.data === 'string') {
|
||||
const data = Buffer.from(config.data);
|
||||
req.end(data);
|
||||
}
|
||||
else if (typeof config.data === 'object') {
|
||||
const data = JSON.stringify(config.data);
|
||||
req.end(data);
|
||||
}
|
||||
}
|
||||
// Create a timeout so the Http2Session will be cleaned up after
|
||||
// a period of non-use. 500 milliseconds was chosen because it's
|
||||
// a nice round number, and I don't know what would be a better
|
||||
// choice. Keeping this channel open will hold a file descriptor
|
||||
// which will prevent the process from exiting.
|
||||
sessionData.timeoutHandle = setTimeout(() => {
|
||||
closeSession(url);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
exports.request = request;
|
||||
/**
|
||||
* By default, throw for any non-2xx status code
|
||||
* @param status - status code from the HTTP response
|
||||
*/
|
||||
function validateStatus(status) {
|
||||
return status >= 200 && status < 300;
|
||||
}
|
||||
/**
|
||||
* Obtain an existing h2 session or go create a new one.
|
||||
* @param host - The hostname to which the session belongs.
|
||||
*/
|
||||
function _getClient(host) {
|
||||
if (!exports.sessions[host]) {
|
||||
if (DEBUG) {
|
||||
console.log(`Creating client for ${host}`);
|
||||
}
|
||||
const session = http2.connect(`https://${host}`);
|
||||
session
|
||||
.on('error', e => {
|
||||
console.error(`*ERROR*: ${e}`);
|
||||
delete exports.sessions[host];
|
||||
})
|
||||
.on('goaway', (errorCode, lastStreamId) => {
|
||||
console.error(`*GOAWAY*: ${errorCode} : ${lastStreamId}`);
|
||||
delete exports.sessions[host];
|
||||
});
|
||||
exports.sessions[host] = { session };
|
||||
}
|
||||
else {
|
||||
if (DEBUG) {
|
||||
console.log(`Used cached client for ${host}`);
|
||||
}
|
||||
}
|
||||
return exports.sessions[host];
|
||||
}
|
||||
async function closeSession(url) {
|
||||
const sessionData = exports.sessions[url.host];
|
||||
if (!sessionData) {
|
||||
return;
|
||||
}
|
||||
const { session } = sessionData;
|
||||
delete exports.sessions[url.host];
|
||||
if (DEBUG) {
|
||||
console.error(`Closing ${url.host}`);
|
||||
}
|
||||
session.close(() => {
|
||||
if (DEBUG) {
|
||||
console.error(`Closed ${url.host}`);
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
if (session && !session.destroyed) {
|
||||
if (DEBUG) {
|
||||
console.log(`Forcing close ${url.host}`);
|
||||
}
|
||||
if (session) {
|
||||
session.destroy();
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
exports.closeSession = closeSession;
|
||||
//# sourceMappingURL=http2.js.map
|
||||
5
node_modules/googleapis-common/build/src/index.d.ts
generated
vendored
5
node_modules/googleapis-common/build/src/index.d.ts
generated
vendored
@@ -1,5 +1,6 @@
|
||||
export { OAuth2Client } from 'google-auth-library';
|
||||
export { APIEndpoint, APIRequestContext, APIRequestParams, BodyResponseCallback, GlobalOptions, GoogleConfigurable, MethodOptions, ServiceOptions, } from './api';
|
||||
export { OAuth2Client, JWT, Compute, UserRefreshClient, DefaultTransporter, GoogleAuth, } from 'google-auth-library';
|
||||
export { GaxiosPromise } from 'gaxios';
|
||||
export { APIEndpoint, APIRequestContext, APIRequestParams, BodyResponseCallback, GlobalOptions, GoogleConfigurable, MethodOptions, StreamMethodOptions, ServiceOptions, } from './api';
|
||||
export { getAPI } from './apiIndex';
|
||||
export { createAPIRequest } from './apirequest';
|
||||
export { AuthPlus } from './authplus';
|
||||
|
||||
19
node_modules/googleapis-common/build/src/index.js
generated
vendored
19
node_modules/googleapis-common/build/src/index.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright 2018, Google, LLC.
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@@ -13,15 +13,20 @@
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var google_auth_library_1 = require("google-auth-library");
|
||||
exports.OAuth2Client = google_auth_library_1.OAuth2Client;
|
||||
Object.defineProperty(exports, "OAuth2Client", { enumerable: true, get: function () { return google_auth_library_1.OAuth2Client; } });
|
||||
Object.defineProperty(exports, "JWT", { enumerable: true, get: function () { return google_auth_library_1.JWT; } });
|
||||
Object.defineProperty(exports, "Compute", { enumerable: true, get: function () { return google_auth_library_1.Compute; } });
|
||||
Object.defineProperty(exports, "UserRefreshClient", { enumerable: true, get: function () { return google_auth_library_1.UserRefreshClient; } });
|
||||
Object.defineProperty(exports, "DefaultTransporter", { enumerable: true, get: function () { return google_auth_library_1.DefaultTransporter; } });
|
||||
Object.defineProperty(exports, "GoogleAuth", { enumerable: true, get: function () { return google_auth_library_1.GoogleAuth; } });
|
||||
var apiIndex_1 = require("./apiIndex");
|
||||
exports.getAPI = apiIndex_1.getAPI;
|
||||
Object.defineProperty(exports, "getAPI", { enumerable: true, get: function () { return apiIndex_1.getAPI; } });
|
||||
var apirequest_1 = require("./apirequest");
|
||||
exports.createAPIRequest = apirequest_1.createAPIRequest;
|
||||
Object.defineProperty(exports, "createAPIRequest", { enumerable: true, get: function () { return apirequest_1.createAPIRequest; } });
|
||||
var authplus_1 = require("./authplus");
|
||||
exports.AuthPlus = authplus_1.AuthPlus;
|
||||
Object.defineProperty(exports, "AuthPlus", { enumerable: true, get: function () { return authplus_1.AuthPlus; } });
|
||||
var discovery_1 = require("./discovery");
|
||||
exports.Discovery = discovery_1.Discovery;
|
||||
Object.defineProperty(exports, "Discovery", { enumerable: true, get: function () { return discovery_1.Discovery; } });
|
||||
var endpoint_1 = require("./endpoint");
|
||||
exports.Endpoint = endpoint_1.Endpoint;
|
||||
Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return endpoint_1.Endpoint; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
15
node_modules/googleapis-common/build/src/isbrowser.d.ts
generated
vendored
15
node_modules/googleapis-common/build/src/isbrowser.d.ts
generated
vendored
@@ -1,16 +1 @@
|
||||
/**
|
||||
* Copyright 2019 Google LLC. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare function isBrowser(): boolean;
|
||||
|
||||
28
node_modules/googleapis-common/build/src/isbrowser.js
generated
vendored
28
node_modules/googleapis-common/build/src/isbrowser.js
generated
vendored
@@ -1,20 +1,18 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2019 Google LLC. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isBrowser = void 0;
|
||||
function isBrowser() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
|
||||
1
node_modules/googleapis-common/build/src/schema.d.ts
generated
vendored
1
node_modules/googleapis-common/build/src/schema.d.ts
generated
vendored
@@ -113,6 +113,7 @@ export interface SchemaMethod {
|
||||
};
|
||||
};
|
||||
};
|
||||
supportsMediaDownload?: boolean;
|
||||
}
|
||||
export interface FragmentResponse {
|
||||
codeFragment: {
|
||||
|
||||
6
node_modules/googleapis-common/build/src/schema.js
generated
vendored
6
node_modules/googleapis-common/build/src/schema.js
generated
vendored
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
// Copyright 2018, Google, LLC.
|
||||
// Copyright 2020 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@@ -11,5 +11,9 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/**
|
||||
* These are a collection of interfaces that represent the GoogleApis
|
||||
* Discovery json formats.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=schema.js.map
|
||||
Reference in New Issue
Block a user