@google-cloud/common
Advanced tools
Comparing version 0.14.0 to 0.15.0
{ | ||
"name": "@google-cloud/common", | ||
"version": "0.14.0", | ||
"description": "Common components for Cloud APIs Node.js Client Libraries", | ||
"version": "0.15.0", | ||
"license": "Apache-2.0", | ||
"author": "Google Inc.", | ||
"description": "Common components for Cloud APIs Node.js Client Libraries", | ||
"contributors": [ | ||
{ | ||
"name": "Burcu Dogan", | ||
"email": "jbd@google.com" | ||
}, | ||
{ | ||
"name": "Johan Euphrosine", | ||
"email": "proppy@google.com" | ||
}, | ||
{ | ||
"name": "Patrick Costello", | ||
"email": "pcostell@google.com" | ||
}, | ||
{ | ||
"name": "Ryan Seys", | ||
"email": "ryan@ryanseys.com" | ||
}, | ||
{ | ||
"name": "Silvano Luciani", | ||
"email": "silvano@google.com" | ||
}, | ||
{ | ||
"name": "Stephen Sawchuk", | ||
"email": "sawchuk@gmail.com" | ||
} | ||
], | ||
"engines": { | ||
"node": ">=4.0.0" | ||
}, | ||
"repository": "googleapis/nodejs-common", | ||
"main": "./src/index.js", | ||
@@ -39,3 +18,29 @@ "files": [ | ||
], | ||
"repository": "googlecloudplatform/google-cloud-node", | ||
"contributors": [ | ||
"Ali Ijaz Sheikh <ofrobots@google.com>", | ||
"Austin Peterson <austin@akpwebdesign.com>", | ||
"Dave Gramlich <callmehiphop@gmail.com>", | ||
"Eric Uldall <ericuldall@gmail.com>", | ||
"Ernest Landrito <landrito@google.com>", | ||
"Jason Dobry <jdobry@google.com>", | ||
"Justin King <jcking@mtu.edu>", | ||
"Karolis Narkevicius <karolis.n@gmail.com>", | ||
"Kelvin Jin <kelvinjin@google.com>", | ||
"Luke Sneeringer <lukesneeringer@google.com>", | ||
"Matthew Loring <matthewloring@users.noreply.github.com>", | ||
"Michael Prentice <splaktar@gmail.com>", | ||
"Stephen Sawchuk <sawchuk@gmail.com>", | ||
"Tim Swast <swast@google.com>" | ||
], | ||
"scripts": { | ||
"publish-module": "node ../../scripts/publish.js common", | ||
"generate-scaffolding": "repo-tools generate all", | ||
"docs": "repo-tools exec -- jsdoc -c .jsdoc.js", | ||
"lint": "repo-tools lint --cmd eslint -- src/ samples/ system-test/ test/", | ||
"prettier": "repo-tools exec -- prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js", | ||
"cover": "nyc --reporter=lcov mocha --require intelli-espower-loader test/*.js && nyc report", | ||
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../", | ||
"test-no-cover": "repo-tools test run --cmd mocha -- test/*.js --no-timeouts", | ||
"test": "repo-tools test run --cmd npm -- run cover" | ||
}, | ||
"dependencies": { | ||
@@ -48,3 +53,3 @@ "array-uniq": "^1.0.3", | ||
"ent": "^2.2.0", | ||
"extend": "^3.0.0", | ||
"extend": "^3.0.1", | ||
"google-auto-auth": "^0.7.1", | ||
@@ -63,14 +68,19 @@ "is": "^3.2.0", | ||
"devDependencies": { | ||
"mocha": "^4.0.0", | ||
"@google-cloud/nodejs-repo-tools": "^2.1.1", | ||
"async": "^2.6.0", | ||
"codecov": "^3.0.0", | ||
"eslint": "^4.10.0", | ||
"eslint-config-prettier": "^2.7.0", | ||
"eslint-plugin-node": "^5.2.1", | ||
"eslint-plugin-prettier": "^2.3.1", | ||
"ink-docstrap": "^1.3.0", | ||
"intelli-espower-loader": "^1.0.1", | ||
"jsdoc": "^3.5.5", | ||
"mocha": "^4.0.1", | ||
"nyc": "^11.3.0", | ||
"power-assert": "^1.4.4", | ||
"prettier": "^1.8.1", | ||
"proxyquire": "^1.7.10", | ||
"uuid": "^3.0.1" | ||
}, | ||
"scripts": { | ||
"publish-module": "node ../../scripts/publish.js common", | ||
"test": "mocha test/*.js" | ||
}, | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=4.0.0" | ||
} | ||
} |
@@ -17,3 +17,3 @@ /*! | ||
'use strict'; | ||
'use strict'; | ||
@@ -32,10 +32,3 @@ /*! | ||
*/ | ||
var LEVELS = [ | ||
'silent', | ||
'error', | ||
'warn', | ||
'info', | ||
'debug', | ||
'silly' | ||
]; | ||
var LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly']; | ||
@@ -49,3 +42,3 @@ /** | ||
* console. (Default: `error`) | ||
* @param {string[]=} options.levels - The list of levels to use. (Default: | ||
* @param {Array.<string>=} options.levels - The list of levels to use. (Default: | ||
* logger.LEVELS) | ||
@@ -57,3 +50,3 @@ * @param {string=} options.tag - A tag to use in log messages. | ||
options = { | ||
level: options | ||
level: options, | ||
}; | ||
@@ -75,5 +68,5 @@ } | ||
tag: options.tag ? ':' + options.tag + ':' : '', | ||
message: args.join(' ') | ||
message: args.join(' '), | ||
}); | ||
} | ||
}, | ||
}); | ||
@@ -80,0 +73,0 @@ } |
@@ -64,10 +64,13 @@ /*! | ||
reqOpts: { | ||
name: config.id | ||
} | ||
} | ||
name: config.id, | ||
}, | ||
}, | ||
}; | ||
config = extend({ | ||
baseUrl: '' | ||
}, config); | ||
config = extend( | ||
{ | ||
baseUrl: '', | ||
}, | ||
config | ||
); | ||
@@ -96,7 +99,5 @@ config.methods = config.methods || methods; | ||
return new self.Promise(function(resolve, reject) { | ||
self | ||
.on('error', reject) | ||
.on('complete', function(metadata) { | ||
resolve([metadata]); | ||
}); | ||
self.on('error', reject).on('complete', function(metadata) { | ||
resolve([metadata]); | ||
}); | ||
}); | ||
@@ -103,0 +104,0 @@ }; |
@@ -142,5 +142,7 @@ /*! | ||
if (callback && | ||
(maxResults !== -1 || // The user specified a limit. | ||
query.autoPaginate === false)) { | ||
if ( | ||
callback && | ||
(maxResults !== -1 || // The user specified a limit. | ||
query.autoPaginate === false) | ||
) { | ||
autoPaginate = false; | ||
@@ -155,3 +157,3 @@ } | ||
maxResults: maxResults, | ||
callback: callback | ||
callback: callback, | ||
}; | ||
@@ -184,5 +186,7 @@ }; | ||
.on('error', callback) | ||
.pipe(concat(function(results) { | ||
callback(null, results); | ||
})); | ||
.pipe( | ||
concat(function(results) { | ||
callback(null, results); | ||
}) | ||
); | ||
} else { | ||
@@ -216,3 +220,3 @@ originalMethod(query, callback); | ||
var limiter = util.createLimiter(makeRequest, { | ||
maxApiCalls: parsedArguments.maxApiCalls | ||
maxApiCalls: parsedArguments.maxApiCalls, | ||
}); | ||
@@ -219,0 +223,0 @@ |
@@ -80,12 +80,8 @@ /*! | ||
.filter(function(methodName) { | ||
return ( | ||
// All ServiceObjects need `request`. | ||
return (// All ServiceObjects need `request`. | ||
!/^request/.test(methodName) && | ||
// The ServiceObject didn't redefine the method. | ||
self[methodName] === ServiceObject.prototype[methodName] && | ||
// This method isn't wanted. | ||
!config.methods[methodName] | ||
); | ||
!config.methods[methodName] ); | ||
}) | ||
@@ -148,6 +144,9 @@ .forEach(function(methodName) { | ||
var reqOpts = extend({ | ||
method: 'DELETE', | ||
uri: '' | ||
}, methodConfig.reqOpts); | ||
var reqOpts = extend( | ||
{ | ||
method: 'DELETE', | ||
uri: '', | ||
}, | ||
methodConfig.reqOpts | ||
); | ||
@@ -260,5 +259,8 @@ // The `request` method may have been overridden to hold any special behavior. | ||
var reqOpts = extend({ | ||
uri: '' | ||
}, methodConfig.reqOpts); | ||
var reqOpts = extend( | ||
{ | ||
uri: '', | ||
}, | ||
methodConfig.reqOpts | ||
); | ||
@@ -295,7 +297,11 @@ // The `request` method may have been overridden to hold any special behavior. | ||
var reqOpts = extend(true, { | ||
method: 'PATCH', | ||
uri: '', | ||
json: metadata | ||
}, methodConfig.reqOpts); | ||
var reqOpts = extend( | ||
true, | ||
{ | ||
method: 'PATCH', | ||
uri: '', | ||
json: metadata, | ||
}, | ||
methodConfig.reqOpts | ||
); | ||
@@ -330,7 +336,3 @@ // The `request` method may have been overridden to hold any special behavior. | ||
var uriComponents = [ | ||
this.baseUrl, | ||
this.id || '', | ||
reqOpts.uri | ||
]; | ||
var uriComponents = [this.baseUrl, this.id || '', reqOpts.uri]; | ||
@@ -337,0 +339,0 @@ if (isAbsoluteUrl) { |
@@ -64,3 +64,3 @@ /*! | ||
keyFile: options.keyFilename, | ||
email: options.email | ||
email: options.email, | ||
}); | ||
@@ -79,3 +79,3 @@ | ||
return reqOpts; | ||
} | ||
}, | ||
}); | ||
@@ -121,5 +121,3 @@ } | ||
var uriComponents = [ | ||
this.baseUrl | ||
]; | ||
var uriComponents = [this.baseUrl]; | ||
@@ -149,3 +147,4 @@ if (this.projectIdRequired) { | ||
// Interceptors should be called in the order they were assigned. | ||
var combinedInterceptors = [].slice.call(this.globalInterceptors) | ||
var combinedInterceptors = [].slice | ||
.call(this.globalInterceptors) | ||
.concat(this.interceptors) | ||
@@ -165,3 +164,3 @@ .concat(arrify(reqOpts.interceptors_)); | ||
'User-Agent': util.getUserAgentFromPackageJson(pkg), | ||
'x-goog-api-client': `gl-node/${process.versions.node} gccl/${pkg.version}` | ||
'x-goog-api-client': `gl-node/${process.versions.node} gccl/${pkg.version}`, | ||
}); | ||
@@ -168,0 +167,0 @@ |
101
src/util.js
@@ -35,4 +35,4 @@ /** | ||
pool: { | ||
maxSockets: Infinity | ||
} | ||
maxSockets: Infinity, | ||
}, | ||
}); | ||
@@ -46,11 +46,14 @@ var retryRequest = require('retry-request'); | ||
var errorMessage = format([ | ||
'Sorry, we cannot connect to Cloud Services without a project ID.', | ||
'You may specify one with an environment variable named "GCLOUD_PROJECT".', | ||
'See {baseUrl}/{path} for a detailed guide on creating an authenticated', | ||
'connection.' | ||
].join(' '), { | ||
baseUrl: 'https://googlecloudplatform.github.io/google-cloud-node/#', | ||
path: 'docs/guides/authentication' | ||
}); | ||
var errorMessage = format( | ||
[ | ||
'Sorry, we cannot connect to Cloud Services without a project ID.', | ||
'You may specify one with an environment variable named "GCLOUD_PROJECT".', | ||
'See {baseUrl}/{path} for a detailed guide on creating an authenticated', | ||
'connection.', | ||
].join(' '), | ||
{ | ||
baseUrl: 'https://googlecloudplatform.github.io/google-cloud-node/#', | ||
path: 'docs/guides/authentication', | ||
} | ||
); | ||
@@ -85,3 +88,5 @@ var missingProjectIdError = new Error(errorMessage); | ||
this.errors = JSON.parse(this.response.body).error.errors; | ||
} catch (e) {} | ||
} catch (e) { | ||
this.errors = errorBody.errors; | ||
} | ||
@@ -133,3 +138,3 @@ var messages = []; | ||
true, | ||
{ err: err || null }, | ||
{err: err || null}, | ||
resp && util.parseHttpRespMessage(resp), | ||
@@ -155,3 +160,3 @@ body && util.parseHttpRespBody(body) | ||
var parsedHttpRespMessage = { | ||
resp: httpRespMessage | ||
resp: httpRespMessage, | ||
}; | ||
@@ -165,3 +170,3 @@ | ||
message: httpRespMessage.statusMessage, | ||
response: httpRespMessage | ||
response: httpRespMessage, | ||
}); | ||
@@ -187,3 +192,3 @@ } | ||
var parsedHttpRespBody = { | ||
body: body | ||
body: body, | ||
}; | ||
@@ -194,3 +199,5 @@ | ||
parsedHttpRespBody.body = JSON.parse(body); | ||
} catch(err) {} | ||
} catch (err) { | ||
parsedHttpRespBody.err = new util.ApiError('Cannot parse JSON response'); | ||
} | ||
} | ||
@@ -236,4 +243,4 @@ | ||
qs: { | ||
uploadType: 'multipart' | ||
} | ||
uploadType: 'multipart', | ||
}, | ||
}; | ||
@@ -247,9 +254,9 @@ | ||
'Content-Type': 'application/json', | ||
body: JSON.stringify(metadata) | ||
body: JSON.stringify(metadata), | ||
}, | ||
{ | ||
'Content-Type': metadata.contentType || 'application/octet-stream', | ||
body: writeStream | ||
} | ||
] | ||
body: writeStream, | ||
}, | ||
], | ||
}); | ||
@@ -275,3 +282,3 @@ | ||
}); | ||
} | ||
}, | ||
}); | ||
@@ -382,3 +389,3 @@ } | ||
err = null; | ||
} catch(e) { | ||
} catch (e) { | ||
// A projectId was required, but we don't have one. | ||
@@ -404,4 +411,7 @@ // Re-use the "Could not load the default credentials error" if auto | ||
} else { | ||
activeRequest_ = | ||
util.makeRequest(authenticatedReqOpts, reqConfig, options); | ||
activeRequest_ = util.makeRequest( | ||
authenticatedReqOpts, | ||
reqConfig, | ||
options | ||
); | ||
} | ||
@@ -428,8 +438,9 @@ } | ||
} | ||
} | ||
}, | ||
}; | ||
} | ||
makeAuthenticatedRequest.getCredentials = | ||
authClient.getCredentials.bind(authClient); | ||
makeAuthenticatedRequest.getCredentials = authClient.getCredentials.bind( | ||
authClient | ||
); | ||
@@ -473,3 +484,3 @@ makeAuthenticatedRequest.authClient = authClient; | ||
return err && util.shouldRetryRequest(err); | ||
} | ||
}, | ||
}; | ||
@@ -492,3 +503,4 @@ | ||
// Replay the Request events back to the stream. | ||
requestStream.on('error', dup.destroy.bind(dup)) | ||
requestStream | ||
.on('error', dup.destroy.bind(dup)) | ||
.on('response', dup.emit.bind(dup, 'response')) | ||
@@ -625,10 +637,5 @@ .on('complete', dup.emit.bind(dup, 'complete')); | ||
* @param {object} localConfig - Service-level configurations. | ||
* @param {object=} options - Configuration object. | ||
* @param {boolean} options.projectIdRequired - Whether to throw if a project ID | ||
* is required, but not provided by the user. (Default: true) | ||
* @return {object} config - Merged and validated configuration. | ||
*/ | ||
function normalizeArguments(globalContext, localConfig, options) { | ||
options = options || {}; | ||
function normalizeArguments(globalContext, localConfig) { | ||
var globalConfig = globalContext && globalContext.config_; | ||
@@ -675,3 +682,3 @@ | ||
stream: stream | ||
stream: stream, | ||
}; | ||
@@ -806,11 +813,11 @@ } | ||
function promisifyAll(Class, options) { | ||
var exclude = options && options.exclude || []; | ||
var exclude = (options && options.exclude) || []; | ||
var methods = Object | ||
.keys(Class.prototype) | ||
.filter(function(methodName) { | ||
return is.fn(Class.prototype[methodName]) && // is it a function? | ||
!/(^\_|(Stream|\_)|promise$)/.test(methodName) && // is it promisable? | ||
exclude.indexOf(methodName) === -1; // is it blacklisted? | ||
}); | ||
var methods = Object.keys(Class.prototype).filter(function(methodName) { | ||
return ( | ||
is.fn(Class.prototype[methodName]) && // is it a function? | ||
!/(^_|(Stream|_)|promise$)/.test(methodName) && // is it promisable? | ||
exclude.indexOf(methodName) === -1 | ||
); // is it blacklisted? | ||
}); | ||
@@ -817,0 +824,0 @@ methods.forEach(function(methodName) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
72836
1658
0
92
16
1
Updatedextend@^3.0.1