@google-cloud/common
Advanced tools
Comparing version 0.16.1 to 0.16.2
{ | ||
"name": "@google-cloud/common", | ||
"description": "Common components for Cloud APIs Node.js Client Libraries", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"license": "Apache-2.0", | ||
@@ -57,3 +57,3 @@ "author": "Google Inc.", | ||
"is": "^3.2.0", | ||
"log-driver": "1.2.5", | ||
"log-driver": "1.2.7", | ||
"methmeth": "^1.1.0", | ||
@@ -78,3 +78,3 @@ "modelo": "^4.2.0", | ||
"intelli-espower-loader": "^1.0.1", | ||
"js-green-licenses": "^0.4.0", | ||
"js-green-licenses": "^0.5.0", | ||
"jsdoc": "^3.5.5", | ||
@@ -84,6 +84,6 @@ "mocha": "^5.0.0", | ||
"power-assert": "^1.4.4", | ||
"prettier": "^1.8.1", | ||
"proxyquire": "^1.7.10", | ||
"prettier": "^1.11.1", | ||
"proxyquire": "^2.0.0", | ||
"uuid": "^3.0.1" | ||
} | ||
} |
@@ -23,5 +23,5 @@ /*! | ||
var format = require('string-format-obj'); | ||
var is = require('is'); | ||
var logDriver = require('log-driver'); | ||
const format = require('string-format-obj'); | ||
const is = require('is'); | ||
const logDriver = require('log-driver'); | ||
@@ -32,3 +32,3 @@ /** | ||
*/ | ||
var LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly']; | ||
const LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly']; | ||
@@ -61,3 +61,3 @@ /** | ||
format: function() { | ||
var args = [].slice.call(arguments); | ||
const args = [].slice.call(arguments); | ||
@@ -64,0 +64,0 @@ return format('{level}{tag} {message}', { |
@@ -23,5 +23,5 @@ /*! | ||
var events = require('events'); | ||
var extend = require('extend'); | ||
var modelo = require('modelo'); | ||
const events = require('events'); | ||
const extend = require('extend'); | ||
const modelo = require('modelo'); | ||
@@ -32,3 +32,3 @@ /** | ||
*/ | ||
var ServiceObject = require('./service-object.js'); | ||
const ServiceObject = require('./service-object.js'); | ||
@@ -50,3 +50,3 @@ // jscs:disable maximumLineLength | ||
function Operation(config) { | ||
var methods = { | ||
const methods = { | ||
/** | ||
@@ -98,3 +98,3 @@ * Checks to see if an operation exists. | ||
Operation.prototype.promise = function() { | ||
var self = this; | ||
const self = this; | ||
@@ -119,3 +119,3 @@ return new self.Promise(function(resolve, reject) { | ||
Operation.prototype.listenForEvents_ = function() { | ||
var self = this; | ||
const self = this; | ||
@@ -177,3 +177,3 @@ this.on('newListener', function(event) { | ||
Operation.prototype.startPolling_ = function() { | ||
var self = this; | ||
const self = this; | ||
@@ -180,0 +180,0 @@ if (!this.hasActiveListeners) { |
@@ -23,7 +23,7 @@ /*! | ||
var arrify = require('arrify'); | ||
var concat = require('concat-stream'); | ||
var extend = require('extend'); | ||
var is = require('is'); | ||
var split = require('split-array-stream'); | ||
const arrify = require('arrify'); | ||
const concat = require('concat-stream'); | ||
const extend = require('extend'); | ||
const is = require('is'); | ||
const split = require('split-array-stream'); | ||
@@ -34,3 +34,3 @@ /** | ||
*/ | ||
var util = require('./util.js'); | ||
const util = require('./util.js'); | ||
@@ -55,3 +55,3 @@ /*! Developer Documentation | ||
*/ | ||
var paginator = {}; | ||
const paginator = {}; | ||
@@ -68,3 +68,3 @@ /** | ||
methodNames.forEach(function(methodName) { | ||
var originalMethod = Class.prototype[methodName]; | ||
const originalMethod = Class.prototype[methodName]; | ||
@@ -76,3 +76,3 @@ // map the original method to a private member | ||
Class.prototype[methodName] = function() { | ||
var parsedArguments = paginator.parseArguments_(arguments); | ||
const parsedArguments = paginator.parseArguments_(arguments); | ||
return paginator.run_(parsedArguments, originalMethod.bind(this)); | ||
@@ -97,4 +97,4 @@ }; | ||
return function() { | ||
var parsedArguments = paginator.parseArguments_(arguments); | ||
var originalMethod = this[methodName + '_'] || this[methodName]; | ||
const parsedArguments = paginator.parseArguments_(arguments); | ||
const originalMethod = this[methodName + '_'] || this[methodName]; | ||
@@ -112,10 +112,10 @@ return paginator.runAsStream_(parsedArguments, originalMethod.bind(this)); | ||
paginator.parseArguments_ = function(args) { | ||
var query; | ||
var autoPaginate = true; | ||
var maxApiCalls = -1; | ||
var maxResults = -1; | ||
var callback; | ||
let query; | ||
let autoPaginate = true; | ||
let maxApiCalls = -1; | ||
let maxResults = -1; | ||
let callback; | ||
var firstArgument = args[0]; | ||
var lastArgument = args[args.length - 1]; | ||
const firstArgument = args[0]; | ||
const lastArgument = args[args.length - 1]; | ||
@@ -158,3 +158,3 @@ if (is.fn(firstArgument)) { | ||
var parsedArguments = { | ||
const parsedArguments = { | ||
query: query || {}, | ||
@@ -192,5 +192,5 @@ autoPaginate: autoPaginate, | ||
paginator.run_ = function(parsedArguments, originalMethod) { | ||
var query = parsedArguments.query; | ||
var callback = parsedArguments.callback; | ||
var autoPaginate = parsedArguments.autoPaginate; | ||
const query = parsedArguments.query; | ||
const callback = parsedArguments.callback; | ||
const autoPaginate = parsedArguments.autoPaginate; | ||
@@ -229,6 +229,6 @@ if (autoPaginate) { | ||
paginator.runAsStream_ = function(parsedArguments, originalMethod) { | ||
var query = parsedArguments.query; | ||
var resultsToSend = parsedArguments.maxResults; | ||
let query = parsedArguments.query; | ||
let resultsToSend = parsedArguments.maxResults; | ||
var limiter = util.createLimiter(makeRequest, { | ||
const limiter = util.createLimiter(makeRequest, { | ||
maxApiCalls: parsedArguments.maxApiCalls, | ||
@@ -238,3 +238,3 @@ streamOptions: parsedArguments.streamOptions, | ||
var stream = limiter.stream; | ||
const stream = limiter.stream; | ||
@@ -241,0 +241,0 @@ stream.once('reading', function() { |
@@ -23,6 +23,6 @@ /*! | ||
var arrify = require('arrify'); | ||
var exec = require('methmeth'); | ||
var extend = require('extend'); | ||
var is = require('is'); | ||
const arrify = require('arrify'); | ||
const exec = require('methmeth'); | ||
const extend = require('extend'); | ||
const is = require('is'); | ||
@@ -33,3 +33,3 @@ /** | ||
*/ | ||
var util = require('./util.js'); | ||
const util = require('./util.js'); | ||
@@ -66,3 +66,3 @@ /** | ||
function ServiceObject(config) { | ||
var self = this; | ||
const self = this; | ||
@@ -80,6 +80,7 @@ this.metadata = {}; | ||
if (config.methods) { | ||
var allMethodNames = Object.keys(ServiceObject.prototype); | ||
const allMethodNames = Object.keys(ServiceObject.prototype); | ||
allMethodNames | ||
.filter(function(methodName) { | ||
return (// All ServiceObjects need `request`. | ||
return ( | ||
// All ServiceObjects need `request`. | ||
!/^request/.test(methodName) && | ||
@@ -89,3 +90,4 @@ // The ServiceObject didn't redefine the method. | ||
// This method isn't wanted. | ||
!config.methods[methodName] ); | ||
!config.methods[methodName] | ||
); | ||
}) | ||
@@ -108,4 +110,4 @@ .forEach(function(methodName) { | ||
ServiceObject.prototype.create = function(options, callback) { | ||
var self = this; | ||
var args = [this.id]; | ||
const self = this; | ||
const args = [this.id]; | ||
@@ -123,3 +125,3 @@ if (is.fn(options)) { | ||
function onCreate(err, instance) { | ||
var args = [].slice.call(arguments); | ||
const args = [].slice.call(arguments); | ||
@@ -147,6 +149,6 @@ if (!err) { | ||
ServiceObject.prototype.delete = function(callback) { | ||
var methodConfig = this.methods.delete || {}; | ||
const methodConfig = this.methods.delete || {}; | ||
callback = callback || util.noop; | ||
var reqOpts = extend( | ||
const reqOpts = extend( | ||
{ | ||
@@ -203,3 +205,3 @@ method: 'DELETE', | ||
ServiceObject.prototype.get = function(config, callback) { | ||
var self = this; | ||
const self = this; | ||
@@ -213,3 +215,3 @@ if (is.fn(config)) { | ||
var autoCreate = config.autoCreate && is.fn(this.create); | ||
const autoCreate = config.autoCreate && is.fn(this.create); | ||
delete config.autoCreate; | ||
@@ -234,3 +236,3 @@ | ||
if (err.code === 404 && autoCreate) { | ||
var args = []; | ||
const args = []; | ||
@@ -264,7 +266,7 @@ if (!is.empty(config)) { | ||
ServiceObject.prototype.getMetadata = function(callback) { | ||
var self = this; | ||
const self = this; | ||
var methodConfig = this.methods.getMetadata || {}; | ||
const methodConfig = this.methods.getMetadata || {}; | ||
var reqOpts = extend( | ||
const reqOpts = extend( | ||
{ | ||
@@ -300,9 +302,9 @@ uri: '', | ||
ServiceObject.prototype.setMetadata = function(metadata, callback) { | ||
var self = this; | ||
const self = this; | ||
callback = callback || util.noop; | ||
var methodConfig = this.methods.setMetadata || {}; | ||
const methodConfig = this.methods.setMetadata || {}; | ||
var reqOpts = extend( | ||
const reqOpts = extend( | ||
true, | ||
@@ -343,5 +345,5 @@ { | ||
var isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; | ||
const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; | ||
var uriComponents = [this.baseUrl, this.id || '', reqOpts.uri]; | ||
const uriComponents = [this.baseUrl, this.id || '', reqOpts.uri]; | ||
@@ -355,3 +357,3 @@ if (isAbsoluteUrl) { | ||
.map(function(uriComponent) { | ||
var trimSlashesRegex = /^\/*|\/*$/g; | ||
const trimSlashesRegex = /^\/*|\/*$/g; | ||
return uriComponent.replace(trimSlashesRegex, ''); | ||
@@ -361,4 +363,4 @@ }) | ||
var childInterceptors = arrify(reqOpts.interceptors_); | ||
var localInterceptors = [].slice.call(this.interceptors); | ||
const childInterceptors = arrify(reqOpts.interceptors_); | ||
const localInterceptors = [].slice.call(this.interceptors); | ||
@@ -365,0 +367,0 @@ reqOpts.interceptors_ = childInterceptors.concat(localInterceptors); |
@@ -23,4 +23,4 @@ /*! | ||
var arrify = require('arrify'); | ||
var extend = require('extend'); | ||
const arrify = require('arrify'); | ||
const extend = require('extend'); | ||
@@ -31,5 +31,5 @@ /** | ||
*/ | ||
var util = require('./util.js'); | ||
const util = require('./util.js'); | ||
var PROJECT_ID_TOKEN = '{{projectId}}'; | ||
const PROJECT_ID_TOKEN = '{{projectId}}'; | ||
@@ -61,3 +61,3 @@ /** | ||
var reqCfg = extend({}, config, { | ||
const reqCfg = extend({}, config, { | ||
projectIdRequired: this.projectIdRequired, | ||
@@ -74,3 +74,3 @@ projectId: this.projectId, | ||
var isCloudFunctionEnv = !!process.env.FUNCTION_NAME; | ||
const isCloudFunctionEnv = !!process.env.FUNCTION_NAME; | ||
@@ -93,3 +93,3 @@ if (isCloudFunctionEnv) { | ||
Service.prototype.getProjectId = function(callback) { | ||
var self = this; | ||
const self = this; | ||
@@ -122,5 +122,5 @@ this.authClient.getProjectId(function(err, projectId) { | ||
var isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; | ||
const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; | ||
var uriComponents = [this.baseUrl]; | ||
const uriComponents = [this.baseUrl]; | ||
@@ -140,3 +140,3 @@ if (this.projectIdRequired) { | ||
.map(function(uriComponent) { | ||
var trimSlashesRegex = /^\/*|\/*$/g; | ||
const trimSlashesRegex = /^\/*|\/*$/g; | ||
return uriComponent.replace(trimSlashesRegex, ''); | ||
@@ -151,3 +151,3 @@ }) | ||
// Interceptors should be called in the order they were assigned. | ||
var combinedInterceptors = [].slice | ||
const combinedInterceptors = [].slice | ||
.call(this.globalInterceptors) | ||
@@ -157,3 +157,3 @@ .concat(this.interceptors) | ||
var interceptor; | ||
let interceptor; | ||
@@ -166,3 +166,3 @@ while ((interceptor = combinedInterceptors.shift()) && interceptor.request) { | ||
var pkg = this.packageJson; | ||
const pkg = this.packageJson; | ||
reqOpts.headers = extend({}, reqOpts.headers, { | ||
@@ -169,0 +169,0 @@ 'User-Agent': util.getUserAgentFromPackageJson(pkg), |
133
src/util.js
@@ -23,10 +23,10 @@ /** | ||
var createErrorClass = require('create-error-class'); | ||
var duplexify = require('duplexify'); | ||
var ent = require('ent'); | ||
var extend = require('extend'); | ||
var format = require('string-format-obj'); | ||
var googleAuth = require('google-auto-auth'); | ||
var is = require('is'); | ||
var request = require('request').defaults({ | ||
const createErrorClass = require('create-error-class'); | ||
const duplexify = require('duplexify'); | ||
const ent = require('ent'); | ||
const extend = require('extend'); | ||
const format = require('string-format-obj'); | ||
const googleAuth = require('google-auto-auth'); | ||
const is = require('is'); | ||
const request = require('request').defaults({ | ||
timeout: 60000, | ||
@@ -39,10 +39,10 @@ gzip: true, | ||
}); | ||
var retryRequest = require('retry-request'); | ||
var streamEvents = require('stream-events'); | ||
var through = require('through2'); | ||
var uniq = require('array-uniq'); | ||
const retryRequest = require('retry-request'); | ||
const streamEvents = require('stream-events'); | ||
const through = require('through2'); | ||
const uniq = require('array-uniq'); | ||
var util = module.exports; | ||
const util = module.exports; | ||
var errorMessage = format( | ||
const errorMessage = format( | ||
[ | ||
@@ -60,3 +60,3 @@ 'Sorry, we cannot connect to Cloud Services without a project ID.', | ||
var missingProjectIdError = new Error(errorMessage); | ||
const missingProjectIdError = new Error(errorMessage); | ||
@@ -93,3 +93,3 @@ util.missingProjectIdError = missingProjectIdError; | ||
var messages = []; | ||
const messages = []; | ||
@@ -117,3 +117,3 @@ if (errorBody.message) { | ||
util.PartialFailureError = createErrorClass('PartialFailureError', function(b) { | ||
var errorObject = b; | ||
const errorObject = b; | ||
@@ -123,3 +123,3 @@ this.errors = errorObject.errors; | ||
var defaultErrorMessage = 'A failure occurred during this request.'; | ||
const defaultErrorMessage = 'A failure occurred during this request.'; | ||
this.message = errorObject.message || defaultErrorMessage; | ||
@@ -139,3 +139,3 @@ }); | ||
var parsedResp = extend( | ||
const parsedResp = extend( | ||
true, | ||
@@ -162,3 +162,3 @@ {err: err || null}, | ||
function parseHttpRespMessage(httpRespMessage) { | ||
var parsedHttpRespMessage = { | ||
const parsedHttpRespMessage = { | ||
resp: httpRespMessage, | ||
@@ -193,3 +193,3 @@ }; | ||
function parseHttpRespBody(body) { | ||
var parsedHttpRespBody = { | ||
const parsedHttpRespBody = { | ||
body: body, | ||
@@ -238,6 +238,6 @@ }; | ||
var writeStream = through(); | ||
const writeStream = through(); | ||
dup.setWritable(writeStream); | ||
var defaultReqOpts = { | ||
const defaultReqOpts = { | ||
method: 'POST', | ||
@@ -249,5 +249,5 @@ qs: { | ||
var metadata = options.metadata || {}; | ||
const metadata = options.metadata || {}; | ||
var reqOpts = extend(true, defaultReqOpts, options.request, { | ||
const reqOpts = extend(true, defaultReqOpts, options.request, { | ||
multipart: [ | ||
@@ -304,4 +304,4 @@ { | ||
if (err.errors) { | ||
for (var i in err.errors) { | ||
var reason = err.errors[i].reason; | ||
for (const i in err.errors) { | ||
const reason = err.errors[i].reason; | ||
if (reason === 'rateLimitExceeded') { | ||
@@ -345,3 +345,3 @@ return true; | ||
var googleAutoAuthConfig = extend({}, config); | ||
const googleAutoAuthConfig = extend({}, config); | ||
@@ -352,3 +352,3 @@ if (googleAutoAuthConfig.projectId === '{{projectId}}') { | ||
var authClient = googleAuth(googleAutoAuthConfig); | ||
const authClient = googleAuth(googleAutoAuthConfig); | ||
@@ -366,5 +366,5 @@ /** | ||
function makeAuthenticatedRequest(reqOpts, options) { | ||
var stream; | ||
var reqConfig = extend({}, config); | ||
var activeRequest_; | ||
let stream; | ||
const reqConfig = extend({}, config); | ||
let activeRequest_; | ||
@@ -377,3 +377,3 @@ if (!options) { | ||
function onAuthenticated(err, authenticatedReqOpts) { | ||
var autoAuthFailed = | ||
const autoAuthFailed = | ||
err && | ||
@@ -388,3 +388,3 @@ err.message.indexOf('Could not load the default credentials') > -1; | ||
if (!err || autoAuthFailed) { | ||
var projectId = authClient.projectId; | ||
let projectId = authClient.projectId; | ||
@@ -485,3 +485,3 @@ if (config.projectId && config.projectId !== '{{projectId}}') { | ||
var options = { | ||
const options = { | ||
request: request, | ||
@@ -492,3 +492,3 @@ | ||
shouldRetryFn: function(httpRespMessage) { | ||
var err = util.parseHttpRespMessage(httpRespMessage).err; | ||
const err = util.parseHttpRespMessage(httpRespMessage).err; | ||
return err && util.shouldRetryRequest(err); | ||
@@ -499,5 +499,5 @@ }, | ||
if (config.stream) { | ||
var dup = config.stream; | ||
var requestStream; | ||
var isGetRequest = (reqOpts.method || 'GET').toUpperCase() === 'GET'; | ||
const dup = config.stream; | ||
let requestStream; | ||
const isGetRequest = (reqOpts.method || 'GET').toUpperCase() === 'GET'; | ||
@@ -578,3 +578,3 @@ if (isGetRequest) { | ||
if (is.object(value) && is.fn(value.hasOwnProperty)) { | ||
for (var opt in value) { | ||
for (const opt in value) { | ||
if (value.hasOwnProperty(opt)) { | ||
@@ -616,3 +616,3 @@ value[opt] = replaceProjectIdToken(value[opt], projectId); | ||
var defaultConfig = {}; | ||
const defaultConfig = {}; | ||
@@ -623,6 +623,6 @@ if (process.env.GCLOUD_PROJECT) { | ||
var options = extend({}, globalConfig); | ||
const options = extend({}, globalConfig); | ||
var hasGlobalConnection = options.credentials || options.keyFilename; | ||
var isOverridingConnection = overrides.credentials || overrides.keyFilename; | ||
const hasGlobalConnection = options.credentials || options.keyFilename; | ||
const isOverridingConnection = overrides.credentials || overrides.keyFilename; | ||
@@ -634,3 +634,3 @@ if (hasGlobalConnection && isOverridingConnection) { | ||
var extendedConfig = extend(true, defaultConfig, options, overrides); | ||
const extendedConfig = extend(true, defaultConfig, options, overrides); | ||
@@ -654,3 +654,3 @@ // Preserve the original (not cloned) interceptors. | ||
function normalizeArguments(globalContext, localConfig) { | ||
var globalConfig = globalContext && globalContext.config_; | ||
const globalConfig = globalContext && globalContext.config_; | ||
@@ -675,6 +675,6 @@ return util.extendGlobalConfig(globalConfig, localConfig); | ||
var stream = streamEvents(through.obj(options.streamOptions)); | ||
const stream = streamEvents(through.obj(options.streamOptions)); | ||
var requestsMade = 0; | ||
var requestsToMake = -1; | ||
let requestsMade = 0; | ||
let requestsToMake = -1; | ||
@@ -710,6 +710,7 @@ if (is.number(options.maxApiCalls)) { | ||
var moduleNameParts = module.split('/'); | ||
const moduleNameParts = module.split('/'); | ||
var parentModuleName = moduleNameParts[0] && moduleNameParts[0].toLowerCase(); | ||
var subModuleName = moduleNameParts[1] && moduleNameParts[1].toLowerCase(); | ||
const parentModuleName = | ||
moduleNameParts[0] && moduleNameParts[0].toLowerCase(); | ||
const subModuleName = moduleNameParts[1] && moduleNameParts[1].toLowerCase(); | ||
@@ -720,3 +721,3 @@ if (subModuleName && getConstructorName(unknown) !== subModuleName) { | ||
var walkingModule = unknown; | ||
let walkingModule = unknown; | ||
do { | ||
@@ -740,3 +741,3 @@ if (getConstructorName(walkingModule) === parentModuleName) { | ||
function getUserAgentFromPackageJson(packageJson) { | ||
var hyphenatedPackageName = packageJson.name | ||
const hyphenatedPackageName = packageJson.name | ||
.replace('@google-cloud', 'gcloud-node') // For legacy purposes. | ||
@@ -766,10 +767,10 @@ .replace('/', '-'); // For UA spec-compliance purposes. | ||
var slice = Array.prototype.slice; | ||
const slice = Array.prototype.slice; | ||
var wrapper = function() { | ||
var context = this; | ||
var last; | ||
const wrapper = function() { | ||
const context = this; | ||
let last; | ||
for (last = arguments.length - 1; last >= 0; last--) { | ||
var arg = arguments[last]; | ||
const arg = arguments[last]; | ||
@@ -788,5 +789,5 @@ if (is.undefined(arg)) { | ||
// peel trailing undefined. | ||
var args = slice.call(arguments, 0, last + 1); | ||
const args = slice.call(arguments, 0, last + 1); | ||
var PromiseCtor = Promise; | ||
let PromiseCtor = Promise; | ||
@@ -802,4 +803,4 @@ // Because dedupe will likely create a single install of | ||
args.push(function() { | ||
var callbackArgs = slice.call(arguments); | ||
var err = callbackArgs.shift(); | ||
const callbackArgs = slice.call(arguments); | ||
const err = callbackArgs.shift(); | ||
@@ -835,5 +836,5 @@ if (err) { | ||
function promisifyAll(Class, options) { | ||
var exclude = (options && options.exclude) || []; | ||
const exclude = (options && options.exclude) || []; | ||
var methods = Object.keys(Class.prototype).filter(function(methodName) { | ||
const methods = Object.keys(Class.prototype).filter(function(methodName) { | ||
return ( | ||
@@ -847,3 +848,3 @@ is.fn(Class.prototype[methodName]) && // is it a function? | ||
methods.forEach(function(methodName) { | ||
var originalMethod = Class.prototype[methodName]; | ||
const originalMethod = Class.prototype[methodName]; | ||
@@ -850,0 +851,0 @@ if (!originalMethod.promisified_) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73362
1673
+ Addedlog-driver@1.2.7(transitive)
- Removedlog-driver@1.2.5(transitive)
Updatedlog-driver@1.2.7