@google-cloud/common
Advanced tools
Comparing version 0.32.1 to 1.0.0
@@ -26,3 +26,3 @@ /*! | ||
*/ | ||
export { Service, ServiceConfig, ServiceOptions, StreamRequestOptions } from './service'; | ||
export { Service, ServiceConfig, ServiceOptions, StreamRequestOptions, } from './service'; | ||
/** | ||
@@ -32,3 +32,3 @@ * @type {module:common/serviceObject} | ||
*/ | ||
export { DeleteCallback, ExistsCallback, GetConfig, InstanceResponseCallback, Interceptor, Metadata, MetadataCallback, MetadataResponse, Methods, ResponseCallback, ServiceObject, ServiceObjectConfig, ServiceObjectParent, SetMetadataResponse } from './service-object'; | ||
export { DeleteCallback, ExistsCallback, GetConfig, InstanceResponseCallback, Interceptor, Metadata, MetadataCallback, MetadataResponse, Methods, ResponseCallback, ServiceObject, ServiceObjectConfig, ServiceObjectParent, SetMetadataResponse, } from './service-object'; | ||
/** | ||
@@ -38,2 +38,2 @@ * @type {module:common/util} | ||
*/ | ||
export { Abortable, AbortableDuplex, ApiError, BodyResponseCallback, DecorateRequestOptions, ResponseBody, util } from './util'; | ||
export { Abortable, AbortableDuplex, ApiError, BodyResponseCallback, DecorateRequestOptions, ResponseBody, util, } from './util'; |
@@ -16,2 +16,5 @@ /*! | ||
*/ | ||
/*! | ||
* @module common/operation | ||
*/ | ||
import { MetadataCallback, ServiceObject, ServiceObjectConfig } from './service-object'; | ||
@@ -18,0 +21,0 @@ export declare class Operation<T = any> extends ServiceObject<T> { |
@@ -17,10 +17,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -30,4 +22,4 @@ /*! | ||
*/ | ||
const pify = require("pify"); | ||
const service_object_1 = require("./service-object"); | ||
const util_1 = require("util"); | ||
// tslint:disable-next-line no-any | ||
@@ -140,19 +132,17 @@ class Operation extends service_object_1.ServiceObject { | ||
*/ | ||
startPolling_() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.hasActiveListeners) { | ||
async startPolling_() { | ||
if (!this.hasActiveListeners) { | ||
return; | ||
} | ||
try { | ||
const metadata = await util_1.promisify(this.poll_.bind(this))(); | ||
if (!metadata) { | ||
setTimeout(this.startPolling_.bind(this), 500); | ||
return; | ||
} | ||
try { | ||
const metadata = yield pify(this.poll_.bind(this))(); | ||
if (!metadata) { | ||
setTimeout(this.startPolling_.bind(this), 500); | ||
return; | ||
} | ||
this.emit('complete', metadata); | ||
} | ||
catch (err) { | ||
this.emit('error', err); | ||
} | ||
}); | ||
this.emit('complete', metadata); | ||
} | ||
catch (err) { | ||
this.emit('error', err); | ||
} | ||
} | ||
@@ -159,0 +149,0 @@ } |
@@ -69,3 +69,4 @@ /*! | ||
} | ||
export declare type CreateOptions = {}; | ||
export interface CreateOptions { | ||
} | ||
export declare type CreateResponse<T> = any[]; | ||
@@ -72,0 +73,0 @@ export interface CreateCallback<T> { |
@@ -17,10 +17,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -65,6 +57,5 @@ /*! | ||
email: options.email, | ||
token: options.token | ||
token: options.token, | ||
}); | ||
this.makeAuthenticatedRequest = | ||
util_1.util.makeAuthenticatedRequestFactory(reqCfg); | ||
this.makeAuthenticatedRequest = util_1.util.makeAuthenticatedRequestFactory(reqCfg); | ||
this.authClient = this.makeAuthenticatedRequest.authClient; | ||
@@ -88,10 +79,8 @@ this.getCredentials = this.makeAuthenticatedRequest.getCredentials; | ||
} | ||
getProjectIdAsync() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const projectId = yield this.authClient.getProjectId(); | ||
if (this.projectId === PROJECT_ID_TOKEN && projectId) { | ||
this.projectId = projectId; | ||
} | ||
return this.projectId; | ||
}); | ||
async getProjectIdAsync() { | ||
const projectId = await this.authClient.getProjectId(); | ||
if (this.projectId === PROJECT_ID_TOKEN && projectId) { | ||
this.projectId = projectId; | ||
} | ||
return this.projectId; | ||
} | ||
@@ -111,3 +100,3 @@ request_(reqOpts, callback) { | ||
reqOpts.uri = uriComponents | ||
.map((uriComponent) => { | ||
.map(uriComponent => { | ||
const trimSlashesRegex = /^\/*|\/*$/g; | ||
@@ -122,9 +111,10 @@ return uriComponent.replace(trimSlashesRegex, ''); | ||
// Interceptors should be called in the order they were assigned. | ||
const combinedInterceptors = [] | ||
.slice.call(this.globalInterceptors) | ||
const combinedInterceptors = [].slice | ||
.call(this.globalInterceptors) | ||
.concat(this.interceptors) | ||
.concat(arrify(reqOpts.interceptors_)); | ||
let interceptor; | ||
while ( | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((interceptor = combinedInterceptors.shift()) && | ||
(interceptor = combinedInterceptors.shift()) && | ||
interceptor.request) { | ||
@@ -131,0 +121,0 @@ reqOpts = interceptor.request(reqOpts); |
@@ -49,5 +49,5 @@ /** | ||
} | ||
export declare type Abortable = { | ||
export interface Abortable { | ||
abort(): void; | ||
}; | ||
} | ||
export declare type AbortableDuplex = Duplexify & Abortable; | ||
@@ -54,0 +54,0 @@ export interface PackageJson { |
@@ -229,4 +229,3 @@ "use strict"; | ||
{ | ||
'Content-Type': metadata.contentType || | ||
'application/octet-stream', | ||
'Content-Type': metadata.contentType || 'application/octet-stream', | ||
body: writeStream, | ||
@@ -313,9 +312,6 @@ }, | ||
const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : undefined; | ||
const callback = typeof optionsOrCallback === 'function' ? | ||
optionsOrCallback : | ||
undefined; | ||
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : undefined; | ||
const onAuthenticated = (err, authenticatedReqOpts) => { | ||
const autoAuthFailed = err && | ||
err.message.indexOf('Could not load the default credentials') > | ||
-1; | ||
err.message.indexOf('Could not load the default credentials') > -1; | ||
if (autoAuthFailed) { | ||
@@ -333,4 +329,3 @@ // Even though authentication failed, the API might not actually | ||
try { | ||
authenticatedReqOpts = | ||
util.decorateRequest(authenticatedReqOpts, projectId); | ||
authenticatedReqOpts = util.decorateRequest(authenticatedReqOpts, projectId); | ||
err = null; | ||
@@ -350,5 +345,5 @@ } | ||
else { | ||
const fn = options && options.onAuthenticated ? | ||
options.onAuthenticated : | ||
callback; | ||
const fn = options && options.onAuthenticated | ||
? options.onAuthenticated | ||
: callback; | ||
fn(err); | ||
@@ -362,4 +357,3 @@ } | ||
else { | ||
activeRequest_ = | ||
util.makeRequest(authenticatedReqOpts, reqConfig, callback); | ||
activeRequest_ = util.makeRequest(authenticatedReqOpts, reqConfig, callback); | ||
} | ||
@@ -445,3 +439,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')) | ||
@@ -523,5 +518,5 @@ .on('complete', dup.emit.bind(dup, 'complete')); | ||
maybeOptionsOrCallback(optionsOrCallback, cb) { | ||
return typeof optionsOrCallback === 'function' ? | ||
[{}, optionsOrCallback] : | ||
[optionsOrCallback, cb]; | ||
return typeof optionsOrCallback === 'function' | ||
? [{}, optionsOrCallback] | ||
: [optionsOrCallback, cb]; | ||
} | ||
@@ -528,0 +523,0 @@ } |
@@ -7,2 +7,27 @@ # Changelog | ||
## [1.0.0](https://www.github.com/googleapis/nodejs-common/compare/v0.32.1...v1.0.0) (2019-05-09) | ||
### Bug Fixes | ||
* **deps:** update dependency @google-cloud/projectify to v1 ([#414](https://www.github.com/googleapis/nodejs-common/issues/414)) ([6cdc2fe](https://www.github.com/googleapis/nodejs-common/commit/6cdc2fe)) | ||
* **deps:** update dependency @google-cloud/promisify to v1 ([#415](https://www.github.com/googleapis/nodejs-common/issues/415)) ([00c422a](https://www.github.com/googleapis/nodejs-common/commit/00c422a)) | ||
* **deps:** update dependency google-auth-library to v4 ([#422](https://www.github.com/googleapis/nodejs-common/issues/422)) ([e0a94af](https://www.github.com/googleapis/nodejs-common/commit/e0a94af)) | ||
### Build System | ||
* upgrade engines field to >=8.10.0 ([#412](https://www.github.com/googleapis/nodejs-common/issues/412)) ([4349d68](https://www.github.com/googleapis/nodejs-common/commit/4349d68)) | ||
### Miscellaneous Chores | ||
* **deps:** update dependency gts to v1 ([#407](https://www.github.com/googleapis/nodejs-common/issues/407)) ([8e73d8c](https://www.github.com/googleapis/nodejs-common/commit/8e73d8c)) | ||
### BREAKING CHANGES | ||
* **deps:** this will ship async/await in the generated code | ||
* upgrade engines field to >=8.10.0 (#412) | ||
## v0.32.1 | ||
@@ -344,2 +369,1 @@ | ||
- Update config.yml (#191) | ||
{ | ||
"name": "@google-cloud/common", | ||
"description": "Common components for Cloud APIs Node.js Client Libraries", | ||
"version": "0.32.1", | ||
"version": "1.0.0", | ||
"license": "Apache-2.0", | ||
"author": "Google Inc.", | ||
"engines": { | ||
"node": ">=6.0.0" | ||
"node": ">=8.10.0" | ||
}, | ||
@@ -18,3 +18,2 @@ "repository": "googleapis/nodejs-common", | ||
"scripts": { | ||
"generate-scaffolding": "repo-tools generate all", | ||
"docs": "compodoc src/", | ||
@@ -36,4 +35,4 @@ "test": "nyc mocha build/test", | ||
"dependencies": { | ||
"@google-cloud/projectify": "^0.3.3", | ||
"@google-cloud/promisify": "^0.4.0", | ||
"@google-cloud/projectify": "^1.0.0", | ||
"@google-cloud/promisify": "^1.0.0", | ||
"@types/request": "^2.48.1", | ||
@@ -44,4 +43,3 @@ "arrify": "^2.0.0", | ||
"extend": "^3.0.2", | ||
"google-auth-library": "^3.1.1", | ||
"pify": "^4.0.1", | ||
"google-auth-library": "^4.0.0", | ||
"retry-request": "^4.0.0", | ||
@@ -52,3 +50,2 @@ "teeny-request": "^3.11.3" | ||
"@compodoc/compodoc": "^1.1.9", | ||
"@google-cloud/nodejs-repo-tools": "^3.2.0", | ||
"@types/ent": "^2.2.1", | ||
@@ -59,11 +56,9 @@ "@types/extend": "^3.0.1", | ||
"@types/ncp": "^2.0.1", | ||
"@types/nock": "^9.3.1", | ||
"@types/nock": "^10.0.0", | ||
"@types/node": "^11.13.0", | ||
"@types/pify": "^3.0.2", | ||
"@types/proxyquire": "^1.3.28", | ||
"@types/sinon": "^7.0.10", | ||
"@types/tmp": "0.1.0", | ||
"axios": "^0.18.0", | ||
"codecov": "^3.2.0", | ||
"gts": "^0.9.0", | ||
"gts": "^1.0.0", | ||
"ink-docstrap": "^1.3.2", | ||
@@ -77,3 +72,3 @@ "intelli-espower-loader": "^1.0.1", | ||
"nock": "^10.0.6", | ||
"nyc": "^13.3.0", | ||
"nyc": "^14.0.0", | ||
"power-assert": "^1.6.1", | ||
@@ -80,0 +75,0 @@ "proxyquire": "^2.1.0", |
@@ -0,15 +1,21 @@ | ||
[//]: # "This README.md file is auto-generated, all changes to this file will be lost." | ||
[//]: # "To regenerate it, use `python -m synthtool`." | ||
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/> | ||
# [Google Cloud Common Module: Node.js Client](https://github.com/googlecloudplatform/google-cloud-node) | ||
# [Google Cloud Common: Node.js Client](https://github.com/googleapis/nodejs-common) | ||
[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style=flat)](https://cloud.google.com/terms/launch-stages) | ||
[![release level](https://img.shields.io/badge/release%20level-general%20availability%20%28GA%29-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages) | ||
[![npm version](https://img.shields.io/npm/v/@google-cloud/common.svg)](https://www.npmjs.org/package/@google-cloud/common) | ||
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-common/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-common) | ||
> Node.js Common package | ||
Google Cloud Common node.js module contains stuff used by other Cloud API modules. | ||
* [github.com/googlecloudplatform/google-cloud-node](https://github.com/googlecloudplatform/google-cloud-node) | ||
Common components for Cloud APIs Node.js Client Libraries | ||
* [github.com/googleapis/nodejs-common](https://github.com/googleapis/nodejs-common) | ||
Read more about the client libraries for Cloud APIs, including the older | ||
@@ -22,6 +28,8 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained]. | ||
* [Quickstart](#quickstart) | ||
* [Before you begin](#before-you-begin) | ||
* [Installing the client library](#installing-the-client-library) | ||
* [Using the client library](#using-the-client-library) | ||
* [Versioning](#versioning) | ||
@@ -33,33 +41,27 @@ * [Contributing](#contributing) | ||
### Before you begin | ||
### Installing the client library | ||
1. Select or create a Cloud Platform project. | ||
```bash | ||
npm install @google-cloud/common | ||
``` | ||
[Go to the projects page][projects] | ||
It's unlikely you will need to install this package directly, as it will be | ||
installed as a dependency when you install other `@google-cloud` packages. | ||
1. Enable billing for your project. | ||
[Enable billing][billing] | ||
1. [Set up authentication with a service account][auth] so you can access the | ||
API from your local workstation. | ||
## Versioning | ||
[projects]: https://console.cloud.google.com/project | ||
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing | ||
[auth]: https://cloud.google.com/docs/authentication/getting-started | ||
This library follows [Semantic Versioning](http://semver.org/). | ||
### Installing the package | ||
npm install --save @google-cloud/common | ||
This library is considered to be **General Availability (GA)**. This means it | ||
is stable; the code surface will not change in backwards-incompatible ways | ||
unless absolutely necessary (e.g. because of critical security issues) or with | ||
an extensive deprecation period. Issues and requests against **GA** libraries | ||
are addressed with the highest priority. | ||
It's unlikely you will need to install this package directly, as it will be | ||
installed as a dependency when you install other `@google-cloud` packages. | ||
## Versioning | ||
This library follows [Semantic Versioning](http://semver.org/). | ||
This library is considered to be in **alpha**. This means it is still a | ||
work-in-progress and under active development. Any release is subject to | ||
backwards-incompatible changes at any time. | ||
@@ -72,3 +74,3 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] | ||
Contributions welcome! See the [Contributing Guide](https://github.com/googlecloudplatform/google-cloud-node/blob/master/CONTRIBUTING.md). | ||
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-common/blob/master/CONTRIBUTING.md). | ||
@@ -79,5 +81,10 @@ ## License | ||
See [LICENSE](https://github.com/googlecloudplatform/google-cloud-node/blob/master/LICENSE) | ||
See [LICENSE](https://github.com/googleapis/nodejs-common/blob/master/LICENSE) | ||
[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png | ||
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png | ||
[projects]: https://console.cloud.google.com/project | ||
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing | ||
[auth]: https://cloud.google.com/docs/authentication/getting-started |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
10
28
1
86
104767
1845
+ Added@google-cloud/projectify@1.0.4(transitive)
+ Added@google-cloud/promisify@1.0.4(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedgaxios@2.3.4(transitive)
+ Addedgcp-metadata@2.0.4(transitive)
+ Addedgoogle-auth-library@4.2.6(transitive)
+ Addedgoogle-p12-pem@2.0.5(transitive)
+ Addedgtoken@3.0.2(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedis-stream@2.0.1(transitive)
- Removedpify@^4.0.1
- Removed@google-cloud/projectify@0.3.3(transitive)
- Removed@google-cloud/promisify@0.4.0(transitive)
- Removedgaxios@1.8.4(transitive)
- Removedgcp-metadata@1.0.0(transitive)
- Removedgoogle-auth-library@3.1.2(transitive)
- Removedgoogle-p12-pem@1.0.5(transitive)
- Removedgtoken@2.3.3(transitive)
- Removedpify@4.0.1(transitive)
- Removedsemver@5.7.2(transitive)
Updatedgoogle-auth-library@^4.0.0