..
This commit is contained in:
165
backend/node_modules/googleapis/lib/apirequest.js
generated
vendored
Normal file
165
backend/node_modules/googleapis/lib/apirequest.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
// Copyright 2014-2016, Google, Inc.
|
||||
// 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 });
|
||||
const stream = require("stream");
|
||||
const parseString = require("string-template");
|
||||
const DefaultTransporter = require('google-auth-library/lib/transporters.js');
|
||||
function isReadableStream(obj) {
|
||||
return obj instanceof stream.Stream &&
|
||||
typeof obj._read === 'function' &&
|
||||
typeof obj._readableState === 'object';
|
||||
}
|
||||
function logError(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
function createCallback(callback) {
|
||||
return typeof callback === 'function' ? callback : logError;
|
||||
}
|
||||
function getMissingParams(params, required) {
|
||||
const missing = [];
|
||||
required.forEach(function (param) {
|
||||
// Is the required param in the params object?
|
||||
if (params[param] === undefined) {
|
||||
missing.push(param);
|
||||
}
|
||||
});
|
||||
// If there are any required params missing, return their names in array, otherwise return null
|
||||
return missing.length > 0 ? missing : null;
|
||||
}
|
||||
/**
|
||||
* Create and send request to Google API
|
||||
* @param {object} parameters Parameters used to form request
|
||||
* @param {Function} callback Callback when request finished or error found
|
||||
* @return {Request} Returns Request object or null
|
||||
*/
|
||||
function createAPIRequest(parameters, callback) {
|
||||
let req, body, missingParams;
|
||||
let params = parameters.params;
|
||||
let options = Object.assign({}, parameters.options);
|
||||
// If the params are not present, and callback was passed instead,
|
||||
// use params as the callback and create empty params.
|
||||
if (typeof params === 'function') {
|
||||
callback = params;
|
||||
params = {};
|
||||
}
|
||||
// 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
|
||||
params = Object.assign({}, // New base object
|
||||
parameters.context.google._options.params, // Global params
|
||||
parameters.context._options.params, // Per-client params
|
||||
params // API call params
|
||||
);
|
||||
const media = params.media || {};
|
||||
const resource = params.resource;
|
||||
let authClient = params.auth ||
|
||||
parameters.context._options.auth ||
|
||||
parameters.context.google._options.auth;
|
||||
const defaultMime = typeof media.body === 'string' ? 'text/plain' : 'application/octet-stream';
|
||||
delete params.media;
|
||||
delete params.resource;
|
||||
delete params.auth;
|
||||
// Grab headers from user provided options
|
||||
const headers = params.headers || {};
|
||||
delete params.headers;
|
||||
// Un-alias parameters that were modified due to conflicts with reserved names
|
||||
Object.keys(params).forEach(function (key) {
|
||||
if (key.slice(-1) === '_') {
|
||||
const newKey = key.slice(0, -1);
|
||||
params[newKey] = params[key];
|
||||
delete params[key];
|
||||
}
|
||||
});
|
||||
// Normalize callback
|
||||
callback = createCallback(callback);
|
||||
// Check for missing required parameters in the API request
|
||||
missingParams = getMissingParams(params, parameters.requiredParams);
|
||||
if (missingParams) {
|
||||
// Some params are missing - stop further operations and inform the developer which required
|
||||
// params are not included in the request
|
||||
callback(new Error('Missing required parameters: ' + missingParams.join(', ')));
|
||||
return null;
|
||||
}
|
||||
// Parse urls
|
||||
if (options.url) {
|
||||
options.url = parseString(options.url, params);
|
||||
}
|
||||
if (parameters.mediaUrl) {
|
||||
parameters.mediaUrl = parseString(parameters.mediaUrl, params);
|
||||
}
|
||||
// delete path parameters from the params object so they do not end up in query
|
||||
parameters.pathParams.forEach(function (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 = null;
|
||||
}
|
||||
if (parameters.mediaUrl && media.body) {
|
||||
options.url = parameters.mediaUrl;
|
||||
if (resource) {
|
||||
params.uploadType = 'multipart';
|
||||
options.multipart = [
|
||||
{
|
||||
'Content-Type': 'application/json',
|
||||
body: JSON.stringify(resource)
|
||||
},
|
||||
{
|
||||
'Content-Type': media.mimeType || (resource && resource.mimeType) || defaultMime,
|
||||
body: media.body // can be a readable stream or raw string!
|
||||
}
|
||||
];
|
||||
}
|
||||
else {
|
||||
params.uploadType = 'media';
|
||||
Object.assign(headers, {
|
||||
'Content-Type': media.mimeType || defaultMime
|
||||
});
|
||||
if (isReadableStream(media.body)) {
|
||||
body = media.body;
|
||||
}
|
||||
else {
|
||||
options.body = media.body;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
options.json = resource || ((options.method === 'GET' || options.method === 'DELETE') ? true : {});
|
||||
}
|
||||
options.headers = headers;
|
||||
options.qs = params;
|
||||
options.useQuerystring = true;
|
||||
options = Object.assign({}, parameters.context.google._options, parameters.context._options, options);
|
||||
delete options.auth; // is overridden by our auth code
|
||||
delete options.params; // We handle params ourselves and Request does not recognise 'params'
|
||||
// create request (using authClient or otherwise and return request obj)
|
||||
if (authClient) {
|
||||
req = authClient.request(options, callback);
|
||||
}
|
||||
else {
|
||||
req = new DefaultTransporter().request(options, callback);
|
||||
}
|
||||
if (body) {
|
||||
body.pipe(req);
|
||||
}
|
||||
return req;
|
||||
}
|
||||
/**
|
||||
* Exports createAPIRequest
|
||||
* @type {Function}
|
||||
*/
|
||||
exports.default = createAPIRequest;
|
||||
//# sourceMappingURL=apirequest.js.map
|
||||
1
backend/node_modules/googleapis/lib/apirequest.js.map
generated
vendored
Normal file
1
backend/node_modules/googleapis/lib/apirequest.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
194
backend/node_modules/googleapis/lib/apirequest.ts
generated
vendored
Normal file
194
backend/node_modules/googleapis/lib/apirequest.ts
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
// Copyright 2014-2016, Google, Inc.
|
||||
// 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 * as stream from 'stream';
|
||||
import * as parseString from 'string-template';
|
||||
|
||||
const DefaultTransporter = require('google-auth-library/lib/transporters.js');
|
||||
|
||||
|
||||
function isReadableStream (obj) {
|
||||
return obj instanceof stream.Stream &&
|
||||
typeof (obj as any)._read === 'function' &&
|
||||
typeof (obj as any)._readableState === 'object';
|
||||
}
|
||||
|
||||
function logError (err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
function createCallback (callback) {
|
||||
return typeof callback === 'function' ? callback : logError;
|
||||
}
|
||||
|
||||
function getMissingParams (params, required) {
|
||||
const missing = [];
|
||||
|
||||
required.forEach(function (param) {
|
||||
// Is the required param in the params object?
|
||||
if (params[param] === undefined) {
|
||||
missing.push(param);
|
||||
}
|
||||
});
|
||||
|
||||
// If there are any required params missing, return their names in array, otherwise return null
|
||||
return missing.length > 0 ? missing : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send request to Google API
|
||||
* @param {object} parameters Parameters used to form request
|
||||
* @param {Function} callback Callback when request finished or error found
|
||||
* @return {Request} Returns Request object or null
|
||||
*/
|
||||
function createAPIRequest (parameters, callback) {
|
||||
let req, body, missingParams;
|
||||
let params = parameters.params;
|
||||
let options = Object.assign({}, parameters.options);
|
||||
|
||||
// If the params are not present, and callback was passed instead,
|
||||
// use params as the callback and create empty params.
|
||||
if (typeof params === 'function') {
|
||||
callback = params;
|
||||
params = {};
|
||||
}
|
||||
|
||||
// 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
|
||||
params = Object.assign(
|
||||
{}, // New base object
|
||||
parameters.context.google._options.params, // Global params
|
||||
parameters.context._options.params, // Per-client params
|
||||
params // API call params
|
||||
);
|
||||
|
||||
const media = params.media || {};
|
||||
const resource = params.resource;
|
||||
let authClient = params.auth ||
|
||||
parameters.context._options.auth ||
|
||||
parameters.context.google._options.auth;
|
||||
|
||||
const defaultMime = typeof media.body === 'string' ? 'text/plain' : 'application/octet-stream';
|
||||
delete params.media;
|
||||
delete params.resource;
|
||||
delete params.auth;
|
||||
|
||||
// Grab headers from user provided options
|
||||
const headers = params.headers || {};
|
||||
delete params.headers;
|
||||
|
||||
// Un-alias parameters that were modified due to conflicts with reserved names
|
||||
Object.keys(params).forEach(function (key) {
|
||||
if (key.slice(-1) === '_') {
|
||||
const newKey = key.slice(0, -1);
|
||||
params[newKey] = params[key];
|
||||
delete params[key];
|
||||
}
|
||||
});
|
||||
|
||||
// Normalize callback
|
||||
callback = createCallback(callback);
|
||||
|
||||
// Check for missing required parameters in the API request
|
||||
missingParams = getMissingParams(params, parameters.requiredParams);
|
||||
if (missingParams) {
|
||||
// Some params are missing - stop further operations and inform the developer which required
|
||||
// params are not included in the request
|
||||
callback(new Error('Missing required parameters: ' + missingParams.join(', ')));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Parse urls
|
||||
if (options.url) {
|
||||
options.url = parseString(options.url, params);
|
||||
}
|
||||
if (parameters.mediaUrl) {
|
||||
parameters.mediaUrl = parseString(parameters.mediaUrl, params);
|
||||
}
|
||||
|
||||
// delete path parameters from the params object so they do not end up in query
|
||||
parameters.pathParams.forEach(function (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 = null;
|
||||
}
|
||||
|
||||
if (parameters.mediaUrl && media.body) {
|
||||
options.url = parameters.mediaUrl;
|
||||
if (resource) {
|
||||
params.uploadType = 'multipart';
|
||||
options.multipart = [
|
||||
{
|
||||
'Content-Type': 'application/json',
|
||||
body: JSON.stringify(resource)
|
||||
},
|
||||
{
|
||||
'Content-Type': media.mimeType || (resource && resource.mimeType) || defaultMime,
|
||||
body: media.body // can be a readable stream or raw string!
|
||||
}
|
||||
];
|
||||
} else {
|
||||
params.uploadType = 'media';
|
||||
Object.assign(headers, {
|
||||
'Content-Type': media.mimeType || defaultMime
|
||||
});
|
||||
|
||||
if (isReadableStream(media.body)) {
|
||||
body = media.body;
|
||||
} else {
|
||||
options.body = media.body;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
options.json = resource || (
|
||||
(options.method === 'GET' || options.method === 'DELETE') ? true : {}
|
||||
);
|
||||
}
|
||||
|
||||
options.headers = headers;
|
||||
options.qs = params;
|
||||
options.useQuerystring = true;
|
||||
|
||||
options = Object.assign({},
|
||||
parameters.context.google._options,
|
||||
parameters.context._options,
|
||||
options
|
||||
);
|
||||
delete options.auth; // is overridden by our auth code
|
||||
delete options.params; // We handle params ourselves and Request does not recognise 'params'
|
||||
|
||||
// create request (using authClient or otherwise and return request obj)
|
||||
if (authClient) {
|
||||
req = authClient.request(options, callback);
|
||||
} else {
|
||||
req = new DefaultTransporter().request(options, callback);
|
||||
}
|
||||
|
||||
if (body) {
|
||||
body.pipe(req);
|
||||
}
|
||||
return req;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports createAPIRequest
|
||||
* @type {Function}
|
||||
*/
|
||||
export default createAPIRequest;
|
||||
274
backend/node_modules/googleapis/lib/discovery.js
generated
vendored
Normal file
274
backend/node_modules/googleapis/lib/discovery.js
generated
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
"use strict";
|
||||
// Copyright 2014-2016, Google, Inc.
|
||||
// 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 });
|
||||
const generator_utils_1 = require("../scripts/generator_utils");
|
||||
const async = require("async");
|
||||
const fs = require("fs");
|
||||
const url = require("url");
|
||||
const util = require("util");
|
||||
const apirequest_1 = require("./apirequest");
|
||||
const DefaultTransporter = require("google-auth-library/lib/transporters");
|
||||
const handleError = generator_utils_1.default.handleError;
|
||||
const transporter = new DefaultTransporter();
|
||||
function getPathParams(params) {
|
||||
const pathParams = [];
|
||||
if (typeof params !== 'object') {
|
||||
params = {};
|
||||
}
|
||||
Object.keys(params).forEach(function (key) {
|
||||
if (params[key].location === 'path') {
|
||||
pathParams.push(key);
|
||||
}
|
||||
});
|
||||
return pathParams;
|
||||
}
|
||||
/**
|
||||
* Given a method schema, add a method to a target.
|
||||
*
|
||||
* @private
|
||||
* @param {object} target The target to which to add the method.
|
||||
* @param {object} schema The top-level schema that contains the rootUrl, etc.
|
||||
* @param {object} method The method schema from which to generate the method.
|
||||
* @param {object} context The context to add to the method.
|
||||
*/
|
||||
function makeMethod(schema, method, context) {
|
||||
return function (params, callback) {
|
||||
const url = generator_utils_1.default.buildurl(schema.rootUrl + schema.servicePath + method.path);
|
||||
const parameters = {
|
||||
options: {
|
||||
url: url.substring(1, url.length - 1),
|
||||
method: method.httpMethod
|
||||
},
|
||||
params: params,
|
||||
requiredParams: method.parameterOrder || [],
|
||||
pathParams: getPathParams(method.parameters),
|
||||
context: context,
|
||||
mediaUrl: null
|
||||
};
|
||||
if (method.mediaUpload && method.mediaUpload.protocols &&
|
||||
method.mediaUpload.protocols.simple &&
|
||||
method.mediaUpload.protocols.simple.path) {
|
||||
const mediaUrl = generator_utils_1.default.buildurl(schema.rootUrl +
|
||||
method.mediaUpload.protocols.simple.path);
|
||||
parameters.mediaUrl = mediaUrl.substring(1, mediaUrl.length - 1);
|
||||
}
|
||||
return apirequest_1.default(parameters, callback);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Given a schema, add methods to a target.
|
||||
*
|
||||
* @private
|
||||
* @param {object} target The target to which to apply the methods.
|
||||
* @param {object} rootSchema The top-level schema, so we don't lose track of it
|
||||
* during recursion.
|
||||
* @param {object} schema The current schema from which to extract methods.
|
||||
* @param {object} context The context to add to each method.
|
||||
*/
|
||||
function applyMethodsFromSchema(target, rootSchema, schema, context) {
|
||||
if (schema.methods) {
|
||||
for (const name in schema.methods) {
|
||||
const method = schema.methods[name];
|
||||
target[name] = makeMethod(rootSchema, method, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Given a schema, add methods and resources to a target.
|
||||
*
|
||||
* @private
|
||||
* @param {object} target The target to which to apply the schema.
|
||||
* @param {object} rootSchema The top-level schema, so we don't lose track of it
|
||||
* during recursion.
|
||||
* @param {object} schema The current schema from which to extract methods and
|
||||
* resources.
|
||||
* @param {object} context The context to add to each method.
|
||||
*/
|
||||
function applySchema(target, rootSchema, schema, context) {
|
||||
applyMethodsFromSchema(target, rootSchema, schema, context);
|
||||
if (schema.resources) {
|
||||
for (const resourceName in schema.resources) {
|
||||
const resource = schema.resources[resourceName];
|
||||
if (!target[resourceName]) {
|
||||
target[resourceName] = {};
|
||||
}
|
||||
applySchema(target[resourceName], rootSchema, resource, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Generate and Endpoint from an endpoint schema object.
|
||||
*
|
||||
* @private
|
||||
* @param {object} schema The schema from which to generate the Endpoint.
|
||||
* @return Function The Endpoint.
|
||||
*/
|
||||
function makeEndpoint(schema) {
|
||||
const Endpoint = function (options) {
|
||||
const self = this;
|
||||
self._options = options || {};
|
||||
applySchema(self, schema, schema, self);
|
||||
};
|
||||
return Endpoint;
|
||||
}
|
||||
/**
|
||||
* Discovery for discovering API endpoints
|
||||
*
|
||||
* @private
|
||||
* @param {object} options Options for discovery
|
||||
* @this {Discovery}
|
||||
*/
|
||||
function Discovery(options) {
|
||||
this.options = options || {};
|
||||
}
|
||||
/**
|
||||
* Log output of generator
|
||||
* Works just like console.log
|
||||
*/
|
||||
Discovery.prototype.log = function () {
|
||||
if (this.options && this.options.debug) {
|
||||
console.log.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Generate all APIs and return as in-memory object.
|
||||
*
|
||||
* @param {function} callback Callback when all APIs have been generated
|
||||
* @throws {Error} If there is an error generating any of the APIs
|
||||
*/
|
||||
Discovery.prototype.discoverAllAPIs = function (discoveryUrl, callback) {
|
||||
const self = this;
|
||||
const headers = this.options.includePrivate ? {} : { 'X-User-Ip': '0.0.0.0' };
|
||||
transporter.request({
|
||||
uri: discoveryUrl,
|
||||
headers: headers
|
||||
}, function (err, resp) {
|
||||
if (err) {
|
||||
return handleError(err, callback);
|
||||
}
|
||||
async.parallel(resp.items.map(function (api) {
|
||||
return function (cb) {
|
||||
self.discoverAPI(api.discoveryRestUrl, function (err, _api) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
api.api = _api;
|
||||
cb(null, api);
|
||||
});
|
||||
};
|
||||
}), function (err, apis) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
const versionIndex = {};
|
||||
const apisIndex = {};
|
||||
apis.forEach(function (api) {
|
||||
if (!apisIndex[api.name]) {
|
||||
versionIndex[api.name] = {};
|
||||
apisIndex[api.name] = function (options) {
|
||||
const type = typeof options;
|
||||
let version;
|
||||
if (type === 'string') {
|
||||
version = options;
|
||||
options = {};
|
||||
}
|
||||
else if (type === 'object') {
|
||||
version = options.version;
|
||||
delete options.version;
|
||||
}
|
||||
else {
|
||||
throw new Error('Argument error: Accepts only string or object');
|
||||
}
|
||||
try {
|
||||
const Endpoint = versionIndex[api.name][version];
|
||||
const ep = new Endpoint(options);
|
||||
ep.google = this; // for drive.google.transporter
|
||||
return Object.freeze(ep); // create new & freeze
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(util.format('Unable to load endpoint %s("%s"): %s', api.name, version, e.message));
|
||||
}
|
||||
};
|
||||
}
|
||||
versionIndex[api.name][api.version] = api.api;
|
||||
});
|
||||
return callback(null, apisIndex);
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Generate API file given discovery URL
|
||||
*
|
||||
* @param {String} apiDiscoveryUrl URL or filename of discovery doc for API
|
||||
* @param {function} callback Callback when successful write of API
|
||||
* @throws {Error} If there is an error generating the API.
|
||||
*/
|
||||
Discovery.prototype.discoverAPI = function (apiDiscoveryUrl, callback) {
|
||||
function _generate(err, resp) {
|
||||
if (err) {
|
||||
return handleError(err, callback);
|
||||
}
|
||||
return callback(null, makeEndpoint(resp));
|
||||
}
|
||||
if (typeof apiDiscoveryUrl === 'string') {
|
||||
const parts = url.parse(apiDiscoveryUrl);
|
||||
if (apiDiscoveryUrl && !parts.protocol) {
|
||||
this.log('Reading from file ' + apiDiscoveryUrl);
|
||||
try {
|
||||
return fs.readFile(apiDiscoveryUrl, {
|
||||
encoding: 'utf8'
|
||||
}, function (err, file) {
|
||||
_generate(err, JSON.parse(file));
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
return handleError(err, callback);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.log('Requesting ' + apiDiscoveryUrl);
|
||||
transporter.request({
|
||||
uri: apiDiscoveryUrl
|
||||
}, _generate);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const options = apiDiscoveryUrl;
|
||||
this.log('Requesting ' + options.url);
|
||||
const parameters = {
|
||||
options: {
|
||||
url: options.url,
|
||||
method: 'GET'
|
||||
},
|
||||
requiredParams: [],
|
||||
pathParams: [],
|
||||
params: null,
|
||||
context: {
|
||||
google: {
|
||||
_options: {}
|
||||
},
|
||||
_options: {}
|
||||
}
|
||||
};
|
||||
delete options.url;
|
||||
parameters.params = options;
|
||||
apirequest_1.default(parameters, _generate);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Export the Discovery object
|
||||
* @type {Discovery}
|
||||
*/
|
||||
exports.default = Discovery;
|
||||
//# sourceMappingURL=discovery.js.map
|
||||
1
backend/node_modules/googleapis/lib/discovery.js.map
generated
vendored
Normal file
1
backend/node_modules/googleapis/lib/discovery.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
291
backend/node_modules/googleapis/lib/discovery.ts
generated
vendored
Normal file
291
backend/node_modules/googleapis/lib/discovery.ts
generated
vendored
Normal file
@@ -0,0 +1,291 @@
|
||||
// Copyright 2014-2016, Google, Inc.
|
||||
// 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 generatorUtils from '../scripts/generator_utils';
|
||||
import * as async from 'async';
|
||||
import * as fs from 'fs';
|
||||
import * as url from 'url';
|
||||
import * as util from 'util';
|
||||
import createAPIRequest from './apirequest';
|
||||
import * as DefaultTransporter from 'google-auth-library/lib/transporters';
|
||||
|
||||
const handleError = generatorUtils.handleError;
|
||||
const transporter = new DefaultTransporter();
|
||||
|
||||
function getPathParams (params) {
|
||||
const pathParams = [];
|
||||
if (typeof params !== 'object') {
|
||||
params = {};
|
||||
}
|
||||
Object.keys(params).forEach(function (key) {
|
||||
if (params[key].location === 'path') {
|
||||
pathParams.push(key);
|
||||
}
|
||||
});
|
||||
return pathParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a method schema, add a method to a target.
|
||||
*
|
||||
* @private
|
||||
* @param {object} target The target to which to add the method.
|
||||
* @param {object} schema The top-level schema that contains the rootUrl, etc.
|
||||
* @param {object} method The method schema from which to generate the method.
|
||||
* @param {object} context The context to add to the method.
|
||||
*/
|
||||
function makeMethod (schema, method, context) {
|
||||
return function (params, callback) {
|
||||
const url = generatorUtils.buildurl(schema.rootUrl + schema.servicePath + method.path);
|
||||
|
||||
const parameters = {
|
||||
options: {
|
||||
url: url.substring(1, url.length - 1),
|
||||
method: method.httpMethod
|
||||
},
|
||||
params: params,
|
||||
requiredParams: method.parameterOrder || [],
|
||||
pathParams: getPathParams(method.parameters),
|
||||
context: context,
|
||||
mediaUrl: null
|
||||
};
|
||||
|
||||
if (method.mediaUpload && method.mediaUpload.protocols &&
|
||||
method.mediaUpload.protocols.simple &&
|
||||
method.mediaUpload.protocols.simple.path) {
|
||||
const mediaUrl = generatorUtils.buildurl(
|
||||
schema.rootUrl +
|
||||
method.mediaUpload.protocols.simple.path
|
||||
);
|
||||
parameters.mediaUrl = mediaUrl.substring(1, mediaUrl.length - 1);
|
||||
}
|
||||
|
||||
return createAPIRequest(parameters, callback);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a schema, add methods to a target.
|
||||
*
|
||||
* @private
|
||||
* @param {object} target The target to which to apply the methods.
|
||||
* @param {object} rootSchema The top-level schema, so we don't lose track of it
|
||||
* during recursion.
|
||||
* @param {object} schema The current schema from which to extract methods.
|
||||
* @param {object} context The context to add to each method.
|
||||
*/
|
||||
function applyMethodsFromSchema (target, rootSchema, schema, context) {
|
||||
if (schema.methods) {
|
||||
for (const name in schema.methods) {
|
||||
const method = schema.methods[name];
|
||||
target[name] = makeMethod(rootSchema, method, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a schema, add methods and resources to a target.
|
||||
*
|
||||
* @private
|
||||
* @param {object} target The target to which to apply the schema.
|
||||
* @param {object} rootSchema The top-level schema, so we don't lose track of it
|
||||
* during recursion.
|
||||
* @param {object} schema The current schema from which to extract methods and
|
||||
* resources.
|
||||
* @param {object} context The context to add to each method.
|
||||
*/
|
||||
function applySchema (target, rootSchema, schema, context) {
|
||||
applyMethodsFromSchema(target, rootSchema, schema, context);
|
||||
|
||||
if (schema.resources) {
|
||||
for (const resourceName in schema.resources) {
|
||||
const resource = schema.resources[resourceName];
|
||||
if (!target[resourceName]) {
|
||||
target[resourceName] = {};
|
||||
}
|
||||
applySchema(target[resourceName], rootSchema, resource, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and Endpoint from an endpoint schema object.
|
||||
*
|
||||
* @private
|
||||
* @param {object} schema The schema from which to generate the Endpoint.
|
||||
* @return Function The Endpoint.
|
||||
*/
|
||||
function makeEndpoint (schema) {
|
||||
const Endpoint = function (options) {
|
||||
const self = this;
|
||||
self._options = options || {};
|
||||
|
||||
applySchema(self, schema, schema, self);
|
||||
};
|
||||
return Endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discovery for discovering API endpoints
|
||||
*
|
||||
* @private
|
||||
* @param {object} options Options for discovery
|
||||
* @this {Discovery}
|
||||
*/
|
||||
function Discovery (options) {
|
||||
this.options = options || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Log output of generator
|
||||
* Works just like console.log
|
||||
*/
|
||||
Discovery.prototype.log = function () {
|
||||
if (this.options && this.options.debug) {
|
||||
console.log.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate all APIs and return as in-memory object.
|
||||
*
|
||||
* @param {function} callback Callback when all APIs have been generated
|
||||
* @throws {Error} If there is an error generating any of the APIs
|
||||
*/
|
||||
Discovery.prototype.discoverAllAPIs = function (discoveryUrl, callback) {
|
||||
const self = this;
|
||||
const headers = this.options.includePrivate ? {} : { 'X-User-Ip': '0.0.0.0' };
|
||||
transporter.request({
|
||||
uri: discoveryUrl,
|
||||
headers: headers
|
||||
}, function (err, resp) {
|
||||
if (err) {
|
||||
return handleError(err, callback);
|
||||
}
|
||||
|
||||
async.parallel(resp.items.map(function (api) {
|
||||
return function (cb) {
|
||||
self.discoverAPI(api.discoveryRestUrl, function (err, _api) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
api.api = _api;
|
||||
cb(null, api);
|
||||
});
|
||||
};
|
||||
}), function (err, apis) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
const versionIndex = {};
|
||||
const apisIndex = {};
|
||||
|
||||
apis.forEach(function (api) {
|
||||
if (!apisIndex[api.name]) {
|
||||
versionIndex[api.name] = {};
|
||||
apisIndex[api.name] = function (options) {
|
||||
const type = typeof options;
|
||||
let version;
|
||||
if (type === 'string') {
|
||||
version = options;
|
||||
options = {};
|
||||
} else if (type === 'object') {
|
||||
version = options.version;
|
||||
delete options.version;
|
||||
} else {
|
||||
throw new Error('Argument error: Accepts only string or object');
|
||||
}
|
||||
try {
|
||||
const Endpoint = versionIndex[api.name][version];
|
||||
const ep = new Endpoint(options);
|
||||
ep.google = this; // for drive.google.transporter
|
||||
return Object.freeze(ep); // create new & freeze
|
||||
} catch (e) {
|
||||
throw new Error(util.format('Unable to load endpoint %s("%s"): %s',
|
||||
api.name, version, e.message));
|
||||
}
|
||||
};
|
||||
}
|
||||
versionIndex[api.name][api.version] = api.api;
|
||||
});
|
||||
|
||||
return callback(null, apisIndex);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate API file given discovery URL
|
||||
*
|
||||
* @param {String} apiDiscoveryUrl URL or filename of discovery doc for API
|
||||
* @param {function} callback Callback when successful write of API
|
||||
* @throws {Error} If there is an error generating the API.
|
||||
*/
|
||||
Discovery.prototype.discoverAPI = function (apiDiscoveryUrl, callback) {
|
||||
function _generate (err, resp) {
|
||||
if (err) {
|
||||
return handleError(err, callback);
|
||||
}
|
||||
return callback(null, makeEndpoint(resp));
|
||||
}
|
||||
|
||||
if (typeof apiDiscoveryUrl === 'string') {
|
||||
const parts = url.parse(apiDiscoveryUrl);
|
||||
|
||||
if (apiDiscoveryUrl && !parts.protocol) {
|
||||
this.log('Reading from file ' + apiDiscoveryUrl);
|
||||
try {
|
||||
return fs.readFile(apiDiscoveryUrl, {
|
||||
encoding: 'utf8'
|
||||
}, function (err, file) {
|
||||
_generate(err, JSON.parse(file));
|
||||
});
|
||||
} catch (err) {
|
||||
return handleError(err, callback);
|
||||
}
|
||||
} else {
|
||||
this.log('Requesting ' + apiDiscoveryUrl);
|
||||
transporter.request({
|
||||
uri: apiDiscoveryUrl
|
||||
}, _generate);
|
||||
}
|
||||
} else {
|
||||
const options = apiDiscoveryUrl;
|
||||
this.log('Requesting ' + options.url);
|
||||
const parameters = {
|
||||
options: {
|
||||
url: options.url,
|
||||
method: 'GET'
|
||||
},
|
||||
requiredParams: [],
|
||||
pathParams: [],
|
||||
params: null,
|
||||
context: {
|
||||
google: {
|
||||
_options: {}
|
||||
},
|
||||
_options: {}
|
||||
}
|
||||
};
|
||||
delete options.url;
|
||||
parameters.params = options;
|
||||
createAPIRequest(parameters, _generate);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Export the Discovery object
|
||||
* @type {Discovery}
|
||||
*/
|
||||
export default Discovery;
|
||||
180
backend/node_modules/googleapis/lib/googleapis.js
generated
vendored
Normal file
180
backend/node_modules/googleapis/lib/googleapis.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
"use strict";
|
||||
// Copyright 2012-2016, Google, Inc.
|
||||
// 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.
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const util = require("util");
|
||||
const discovery_1 = require("./discovery");
|
||||
const discovery = new discovery_1.default({ debug: false, includePrivate: false });
|
||||
/**
|
||||
* Load the apis from apis index file
|
||||
* This file holds all version information
|
||||
* @private
|
||||
*/
|
||||
const apis = {};
|
||||
/**
|
||||
* Return a Function that requires an API from the disk
|
||||
* @param {String} filename Filename of API
|
||||
* @return {function} function used to require the API from disk
|
||||
* @private
|
||||
*/
|
||||
function requireAPI(filename) {
|
||||
return function (options) {
|
||||
const type = typeof options;
|
||||
let version;
|
||||
if (type === 'string') {
|
||||
version = options;
|
||||
options = {};
|
||||
}
|
||||
else if (type === 'object') {
|
||||
version = options.version;
|
||||
delete options.version;
|
||||
}
|
||||
else {
|
||||
throw new Error('Argument error: Accepts only string or object');
|
||||
}
|
||||
try {
|
||||
const endpointPath = path.join(__dirname, filename, path.basename(version));
|
||||
const Endpoint = require(endpointPath);
|
||||
const ep = new Endpoint(options);
|
||||
ep.google = this; // for drive.google.transporter
|
||||
return Object.freeze(ep); // create new & freeze
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(util.format('Unable to load endpoint %s("%s"): %s', filename, version, e.message));
|
||||
}
|
||||
};
|
||||
}
|
||||
// Dynamically discover available APIs
|
||||
fs.readdirSync(path.join(__dirname, '../apis')).forEach(function (file) {
|
||||
apis[file] = requireAPI('../apis/' + file);
|
||||
});
|
||||
/**
|
||||
* @class GoogleAuth
|
||||
*/
|
||||
const GoogleAuth = require('google-auth-library');
|
||||
/**
|
||||
* GoogleApis constructor.
|
||||
*
|
||||
* @example
|
||||
* const GoogleApis = require('googleapis').GoogleApis;
|
||||
* const google = new GoogleApis();
|
||||
*
|
||||
* @class GoogleApis
|
||||
* @param {Object} [options] Configuration options.
|
||||
*/
|
||||
function GoogleApis(options) {
|
||||
this.options(options);
|
||||
this.addAPIs(apis);
|
||||
/**
|
||||
* A reference to an instance of GoogleAuth.
|
||||
*
|
||||
* @name GoogleApis#auth
|
||||
* @type {GoogleAuth}
|
||||
*/
|
||||
this.auth = new GoogleAuth();
|
||||
/**
|
||||
* A reference to the {@link GoogleApis} constructor function.
|
||||
*
|
||||
* @name GoogleApis#GoogleApis
|
||||
* @see GoogleApis
|
||||
* @type {Function}
|
||||
*/
|
||||
this.GoogleApis = GoogleApis;
|
||||
}
|
||||
/**
|
||||
* Set options.
|
||||
*
|
||||
* @param {Object} [options] Configuration options.
|
||||
*/
|
||||
GoogleApis.prototype.options = function (options) {
|
||||
this._options = options || {};
|
||||
};
|
||||
/**
|
||||
* Add APIs endpoints to googleapis object
|
||||
* E.g. googleapis.drive and googleapis.datastore
|
||||
*
|
||||
* @name GoogleApis#addAPIs
|
||||
* @method
|
||||
* @param {Object} apis Apis to be added to this GoogleApis instance.
|
||||
* @private
|
||||
*/
|
||||
GoogleApis.prototype.addAPIs = function (apis) {
|
||||
for (const apiName in apis) {
|
||||
this[apiName] = apis[apiName].bind(this);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Dynamically generate an apis object that can provide Endpoint objects for the
|
||||
* discovered APIs.
|
||||
*
|
||||
* @example
|
||||
* const google = require('googleapis');
|
||||
* const discoveryUrl = 'https://myapp.appspot.com/_ah/api/discovery/v1/apis/';
|
||||
* google.discover(discoveryUrl, function (err) {
|
||||
* const someapi = google.someapi('v1');
|
||||
* });
|
||||
*
|
||||
* @name GoogleApis#discover
|
||||
* @method
|
||||
* @param {string} url Url to the discovery service for a set of APIs. e.g.,
|
||||
* https://www.googleapis.com/discovery/v1/apis
|
||||
* @param {Function} callback Callback function.
|
||||
*/
|
||||
GoogleApis.prototype.discover = function (url, callback) {
|
||||
const self = this;
|
||||
discovery.discoverAllAPIs(url, function (err, apis) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
self.addAPIs(apis);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Dynamically generate an Endpoint object from a discovery doc.
|
||||
*
|
||||
* @example
|
||||
* const google = require('google');
|
||||
* const discoveryDocUrl = 'https://myapp.appspot.com/_ah/api/discovery/v1/apis/someapi/v1/rest';
|
||||
* google.discoverApi(discoveryDocUrl, function (err, someapi) {
|
||||
* // use someapi
|
||||
* });
|
||||
*
|
||||
* @name GoogleApis#discoverAPI
|
||||
* @method
|
||||
* @param {string} path Url or file path to discover doc for a single API.
|
||||
* @param {object} [options] Options to configure the Endpoint object generated
|
||||
* from the discovery doc.
|
||||
* @param {Function} callback Callback function.
|
||||
*/
|
||||
GoogleApis.prototype.discoverAPI = function (path, options, callback) {
|
||||
const self = this;
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
discovery.discoverAPI(path, function (err, Endpoint) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
const ep = new Endpoint(options);
|
||||
ep.google = self; // for drive.google.transporter
|
||||
return callback(null, Object.freeze(ep)); // create new & freeze
|
||||
});
|
||||
};
|
||||
module.exports = new GoogleApis();
|
||||
//# sourceMappingURL=googleapis.js.map
|
||||
1
backend/node_modules/googleapis/lib/googleapis.js.map
generated
vendored
Normal file
1
backend/node_modules/googleapis/lib/googleapis.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"googleapis.js","sourceRoot":"","sources":["googleapis.ts"],"names":[],"mappings":"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"}
|
||||
214
backend/node_modules/googleapis/lib/googleapis.ts
generated
vendored
Normal file
214
backend/node_modules/googleapis/lib/googleapis.ts
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
// Copyright 2012-2016, Google, Inc.
|
||||
// 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 * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as util from 'util';
|
||||
import Discovery from './discovery';
|
||||
|
||||
const discovery = new Discovery({ debug: false, includePrivate: false });
|
||||
|
||||
/**
|
||||
* Load the apis from apis index file
|
||||
* This file holds all version information
|
||||
* @private
|
||||
*/
|
||||
const apis = {};
|
||||
|
||||
/**
|
||||
* Return a Function that requires an API from the disk
|
||||
* @param {String} filename Filename of API
|
||||
* @return {function} function used to require the API from disk
|
||||
* @private
|
||||
*/
|
||||
function requireAPI (filename) {
|
||||
return function (options) {
|
||||
const type = typeof options;
|
||||
let version;
|
||||
if (type === 'string') {
|
||||
version = options;
|
||||
options = {};
|
||||
} else if (type === 'object') {
|
||||
version = options.version;
|
||||
delete options.version;
|
||||
} else {
|
||||
throw new Error('Argument error: Accepts only string or object');
|
||||
}
|
||||
try {
|
||||
const endpointPath = path.join(__dirname, filename, path.basename(version));
|
||||
const Endpoint = require(endpointPath);
|
||||
const ep = new Endpoint(options);
|
||||
ep.google = this; // for drive.google.transporter
|
||||
return Object.freeze(ep); // create new & freeze
|
||||
} catch (e) {
|
||||
throw new Error(util.format('Unable to load endpoint %s("%s"): %s',
|
||||
filename, version, e.message));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Dynamically discover available APIs
|
||||
fs.readdirSync(path.join(__dirname, '../apis')).forEach(function (file) {
|
||||
apis[file] = requireAPI('../apis/' + file);
|
||||
});
|
||||
|
||||
/**
|
||||
* @class GoogleAuth
|
||||
*/
|
||||
const GoogleAuth = require('google-auth-library');
|
||||
|
||||
/**
|
||||
* GoogleApis constructor.
|
||||
*
|
||||
* @example
|
||||
* const GoogleApis = require('googleapis').GoogleApis;
|
||||
* const google = new GoogleApis();
|
||||
*
|
||||
* @class GoogleApis
|
||||
* @param {Object} [options] Configuration options.
|
||||
*/
|
||||
function GoogleApis (options?) {
|
||||
this.options(options);
|
||||
this.addAPIs(apis);
|
||||
|
||||
/**
|
||||
* A reference to an instance of GoogleAuth.
|
||||
*
|
||||
* @name GoogleApis#auth
|
||||
* @type {GoogleAuth}
|
||||
*/
|
||||
this.auth = new GoogleAuth();
|
||||
|
||||
/**
|
||||
* A reference to the {@link GoogleApis} constructor function.
|
||||
*
|
||||
* @name GoogleApis#GoogleApis
|
||||
* @see GoogleApis
|
||||
* @type {Function}
|
||||
*/
|
||||
this.GoogleApis = GoogleApis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options.
|
||||
*
|
||||
* @param {Object} [options] Configuration options.
|
||||
*/
|
||||
GoogleApis.prototype.options = function (options) {
|
||||
this._options = options || {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Add APIs endpoints to googleapis object
|
||||
* E.g. googleapis.drive and googleapis.datastore
|
||||
*
|
||||
* @name GoogleApis#addAPIs
|
||||
* @method
|
||||
* @param {Object} apis Apis to be added to this GoogleApis instance.
|
||||
* @private
|
||||
*/
|
||||
GoogleApis.prototype.addAPIs = function (apis) {
|
||||
for (const apiName in apis) {
|
||||
this[apiName] = apis[apiName].bind(this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dynamically generate an apis object that can provide Endpoint objects for the
|
||||
* discovered APIs.
|
||||
*
|
||||
* @example
|
||||
* const google = require('googleapis');
|
||||
* const discoveryUrl = 'https://myapp.appspot.com/_ah/api/discovery/v1/apis/';
|
||||
* google.discover(discoveryUrl, function (err) {
|
||||
* const someapi = google.someapi('v1');
|
||||
* });
|
||||
*
|
||||
* @name GoogleApis#discover
|
||||
* @method
|
||||
* @param {string} url Url to the discovery service for a set of APIs. e.g.,
|
||||
* https://www.googleapis.com/discovery/v1/apis
|
||||
* @param {Function} callback Callback function.
|
||||
*/
|
||||
GoogleApis.prototype.discover = function (url, callback) {
|
||||
const self = this;
|
||||
|
||||
discovery.discoverAllAPIs(url, function (err, apis) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
self.addAPIs(apis);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Dynamically generate an Endpoint object from a discovery doc.
|
||||
*
|
||||
* @example
|
||||
* const google = require('google');
|
||||
* const discoveryDocUrl = 'https://myapp.appspot.com/_ah/api/discovery/v1/apis/someapi/v1/rest';
|
||||
* google.discoverApi(discoveryDocUrl, function (err, someapi) {
|
||||
* // use someapi
|
||||
* });
|
||||
*
|
||||
* @name GoogleApis#discoverAPI
|
||||
* @method
|
||||
* @param {string} path Url or file path to discover doc for a single API.
|
||||
* @param {object} [options] Options to configure the Endpoint object generated
|
||||
* from the discovery doc.
|
||||
* @param {Function} callback Callback function.
|
||||
*/
|
||||
GoogleApis.prototype.discoverAPI = function (path, options, callback) {
|
||||
const self = this;
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
discovery.discoverAPI(path, function (err, Endpoint) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
const ep = new Endpoint(options);
|
||||
ep.google = self; // for drive.google.transporter
|
||||
return callback(null, Object.freeze(ep)); // create new & freeze
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* {@link GoogleApis} class.
|
||||
*
|
||||
* @name module:googleapis.GoogleApis
|
||||
* @see GoogleApis
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@link GoogleAuth} class.
|
||||
*
|
||||
* @name module:googleapis.auth
|
||||
* @see GoogleAuth
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example
|
||||
* const google = require('googleapis');
|
||||
*
|
||||
* @module googleapis
|
||||
* @type {GoogleApis}
|
||||
*/
|
||||
export = new GoogleApis();
|
||||
Reference in New Issue
Block a user