@google-cloud/common
Advanced tools
Comparing version 0.26.2 to 0.27.0
@@ -17,3 +17,3 @@ /*! | ||
import { GetMetadataCallback, ServiceObject, ServiceObjectConfig } from './service-object'; | ||
export declare class Operation extends ServiceObject { | ||
export declare class Operation<T = any> extends ServiceObject<T> { | ||
completeListeners: number; | ||
@@ -20,0 +20,0 @@ hasActiveListeners: boolean; |
@@ -29,5 +29,5 @@ "use strict"; | ||
*/ | ||
const extend = require("extend"); | ||
const pify = require("pify"); | ||
const service_object_1 = require("./service-object"); | ||
// tslint:disable-next-line no-any | ||
class Operation extends service_object_1.ServiceObject { | ||
@@ -63,3 +63,3 @@ /** | ||
}; | ||
config = extend({ | ||
config = Object.assign({ | ||
baseUrl: '', | ||
@@ -66,0 +66,0 @@ }, config); |
@@ -21,2 +21,3 @@ /*! | ||
import { ApiError, BodyResponseCallback, DecorateRequestOptions } from './util'; | ||
export declare type CreateOptions = {}; | ||
export interface ServiceObjectParent { | ||
@@ -69,5 +70,9 @@ Promise?: PromiseConstructor; | ||
} | ||
export interface InstanceResponseCallback { | ||
(err: ApiError | null, instance?: ServiceObject | null, apiResponse?: r.Response): void; | ||
export interface InstanceResponseCallback<T> { | ||
(err: ApiError | null, instance?: T | null, apiResponse?: r.Response): void; | ||
} | ||
export declare type CreateResponse<T> = [T, ...any[]]; | ||
export interface CreateCallback<T> { | ||
(err: ApiError | null, instance?: T | null, ...args: any[]): void; | ||
} | ||
export interface DeleteCallback { | ||
@@ -86,3 +91,3 @@ (err: Error | null, apiResponse?: r.Response): void; | ||
export declare type SetMetadataResponse = [r.Response]; | ||
export declare type GetResponse = [ServiceObject, r.Response]; | ||
export declare type GetResponse<T> = [T, r.Response]; | ||
/** | ||
@@ -99,3 +104,3 @@ * ServiceObject is a base class, meant to be inherited from by a "service | ||
*/ | ||
declare class ServiceObject<CreateOptions extends {} = {}> extends EventEmitter { | ||
declare class ServiceObject<T = any> extends EventEmitter { | ||
metadata: Metadata; | ||
@@ -109,3 +114,2 @@ baseUrl?: string; | ||
Promise?: PromiseConstructor; | ||
[index: string]: any; | ||
requestModule: typeof r; | ||
@@ -122,5 +126,5 @@ constructor(config: ServiceObjectConfig); | ||
*/ | ||
create(options?: CreateOptions): Promise<[ServiceObject, r.Response]>; | ||
create(options: CreateOptions, callback: InstanceResponseCallback): void; | ||
create(callback: InstanceResponseCallback): void; | ||
create(options?: CreateOptions): Promise<CreateResponse<T>>; | ||
create(options: CreateOptions, callback: CreateCallback<T>): void; | ||
create(callback: CreateCallback<T>): void; | ||
/** | ||
@@ -156,5 +160,5 @@ * Delete the object. | ||
*/ | ||
get(config?: GetConfig & CreateOptions): Promise<GetResponse>; | ||
get(callback: InstanceResponseCallback): void; | ||
get(config: GetConfig & CreateOptions, callback: InstanceResponseCallback): void; | ||
get(config?: GetConfig & CreateOptions): Promise<GetResponse<T>>; | ||
get(callback: InstanceResponseCallback<T>): void; | ||
get(config: GetConfig & CreateOptions, callback: InstanceResponseCallback<T>): void; | ||
/** | ||
@@ -161,0 +165,0 @@ * Get the metadata of this object. |
@@ -37,2 +37,3 @@ "use strict"; | ||
*/ | ||
// tslint:disable-next-line no-any | ||
class ServiceObject extends events_1.EventEmitter { | ||
@@ -77,3 +78,6 @@ /* | ||
// The ServiceObject didn't redefine the method. | ||
this[methodName] === ServiceObject.prototype[methodName] && | ||
// tslint:disable-next-line no-any | ||
this[methodName] === | ||
// tslint:disable-next-line no-any | ||
ServiceObject.prototype[methodName] && | ||
// This method isn't wanted. | ||
@@ -83,2 +87,3 @@ !config.methods[methodName]); | ||
.forEach(methodName => { | ||
// tslint:disable-next-line no-any | ||
this[methodName] = undefined; | ||
@@ -85,0 +90,0 @@ }); |
@@ -27,3 +27,3 @@ "use strict"; | ||
const retryRequest = require("retry-request"); | ||
const through = require("through2"); | ||
const stream_1 = require("stream"); | ||
const requestDefaults = { | ||
@@ -193,3 +193,3 @@ timeout: 60000, | ||
onComplete = onComplete || util.noop; | ||
const writeStream = through(); | ||
const writeStream = new stream_1.PassThrough(); | ||
dup.setWritable(writeStream); | ||
@@ -196,0 +196,0 @@ const defaultReqOpts = { |
@@ -7,2 +7,16 @@ # Changelog | ||
## v0.27.0 | ||
11-26-2018 12:26 PST | ||
**BREAKING CHANGE**: The `ServiceObject` class now has stricter TypeScript types for property names. This will have no runtime impact, but may cause TypeScript compilation errors until the issues are addressed. | ||
### Fixes | ||
- fix: improve types for service object ([#310](https://github.com/googleapis/nodejs-common/pull/310)) | ||
- refactor: drop through2, mv, and a few others ([#306](https://github.com/googleapis/nodejs-common/pull/306)) | ||
### Internal / Testing Changes | ||
- chore: add a synth.metadata | ||
- fix: Pin @types/sinon to last compatible version ([#307](https://github.com/googleapis/nodejs-common/pull/307)) | ||
## v0.26.2 | ||
@@ -9,0 +23,0 @@ |
{ | ||
"name": "@google-cloud/common", | ||
"description": "Common components for Cloud APIs Node.js Client Libraries", | ||
"version": "0.26.2", | ||
"version": "0.27.0", | ||
"license": "Apache-2.0", | ||
@@ -15,6 +15,3 @@ "author": "Google Inc.", | ||
"build/src", | ||
"!build/src/**/*.map", | ||
"AUTHORS", | ||
"CONTRIBUTORS", | ||
"LICENSE" | ||
"!build/src/**/*.map" | ||
], | ||
@@ -50,4 +47,3 @@ "scripts": { | ||
"pify": "^4.0.0", | ||
"retry-request": "^4.0.0", | ||
"through2": "^3.0.0" | ||
"retry-request": "^4.0.0" | ||
}, | ||
@@ -66,6 +62,4 @@ "devDependencies": { | ||
"@types/proxyquire": "^1.3.28", | ||
"@types/sinon": "^5.0.1", | ||
"@types/through2": "^2.0.33", | ||
"@types/sinon": "5.0.5", | ||
"@types/tmp": "0.0.33", | ||
"@types/uuid": "^3.4.3", | ||
"axios": "^0.18.0", | ||
@@ -85,9 +79,7 @@ "codecov": "^3.0.2", | ||
"proxyquire": "^2.0.1", | ||
"request": "^2.88.0", | ||
"sinon": "^7.0.0", | ||
"source-map-support": "^0.5.6", | ||
"tmp": "0.0.33", | ||
"typescript": "~3.1.0", | ||
"uuid": "^3.2.1" | ||
"typescript": "~3.1.0" | ||
} | ||
} |
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
95311
11
31
1821
- Removedthrough2@^3.0.0
- Removedthrough2@3.0.2(transitive)