@@ -104,20 +104,22 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
104104 */
105105 apiEndpoint ?: string ;
106106
107+ appProfileId ?: string ;
108+
107109 /**
108110 * Internal only.
109111 */
110- BigtableClient : v2 . BigtableClient ;
112+ BigtableClient ?: gax . ClientOptions ;
111113
112114 /**
113115 * Internal only.
114116 */
115- BigtableInstanceAdminClient : v2 . BigtableInstanceAdminClient ;
117+ BigtableInstanceAdminClient ?: gax . ClientOptions ;
116118
117119 /**
118120 * Internal only.
119121 */
120- BigtableTableAdminClient : v2 . BigtableTableAdminClient ;
122+ BigtableTableAdminClient ?: gax . ClientOptions ;
121123}
122124
123125/**
@@ -197,10 +199,10 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
197199 * const Bigtable = require('@google-cloud/bigtable');
198200 * const bigtable = new Bigtable();
199201 *
200- * const callback = function (err, instance, operation) {
202+ * const callback = (err, instance, operation) => {
201203 * operation
202204 * .on('error', console.log)
203- * .on('complete', function() {
205+ * .on('complete', () => {
204206 * // `instance` is your newly created Instance object.
205207 * });
206208 * };
@@ -283,7 +285,7 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
283285 * }
284286 * ];
285287 *
286- * table.insert(rows, function( err) {
288+ * table.insert(rows, err => {
287289 * if (!err) {
288290 * // Your rows were successfully inserted.
289291 * }
@@ -297,15 +299,15 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
297299 * //-
298300 * table.createReadStream()
299301 * .on('error', console.error)
300- * .on('data', function( row) {
302+ * .on('data', row => {
301303 * // `row` is a Row object.
302304 * });
303305 *
304306 * //-
305307 * // If you're not anticpating a large number of results, a callback mode
306308 * // is also available.
307309 * //-
308- * const callback = function (err, rows) {
310+ * const callback = (err, rows) => {
309311 * // `rows` is an array of Row objects.
310312 * };
311313 *
@@ -326,7 +328,7 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
326328 * //-
327329 * const row = table.row('alincoln');
328330 *
329- * row.get(function( err) {
331+ * row.get(err => {
330332 * // `row.data` is now populated.
331333 * });
332334 *
@@ -378,7 +380,7 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
378380 * // We can delete all of an individual row's cells using
379381 * // {@link Row#delete }.
380382 * //-
381- * const callback = function( err) {
383+ * const callback = err => {
382384 * if (!err) {
383385 * // All cells for this row were deleted successfully.
384386 * }
@@ -408,7 +410,7 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
408410 * prefix: 'gwash'
409411 * };
410412 *
411- * table.deleteRows(options, function( err) {
413+ * table.deleteRows(options, err => {
412414 * if (!err) {
413415 * // Rows were deleted successfully.
414416 * }
@@ -417,14 +419,14 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
417419 * //-
418420 * // If you omit the prefix, you can delete all rows in your table.
419421 * //-
420- * table.deleteRows(function( err) {
422+ * table.deleteRows(err => {
421423 * if (!err) {
422424 * // All rows were deleted successfully.
423425 * }
424426 * });
425427 */
426428export class Bigtable {
427- customEndpoint : string ;
429+ customEndpoint ? : string ;
428430 options : BigtableOptions ;
429431 api : {
430432 [ index : string ] :
@@ -434,13 +436,17 @@ export class Bigtable {
434436 } ;
435437 auth : GoogleAuth ;
436438 projectId : string ;
437- appProfileId : string ;
439+ appProfileId ? : string ;
438440 projectName : string ;
439441 shouldReplaceProjectIdToken : boolean ;
442+ // tslint:disable-next-line variable-name
440443 static AppProfile : AppProfile ;
444+ // tslint:disable-next-line variable-name
441445 static Instance : Instance ;
446+ // tslint:disable-next-line variable-name
442447 static Cluster : Cluster ;
443- constructor ( options : any = { } ) {
448+
449+ constructor ( options : BigtableOptions = { } ) {
444450 // Determine what scopes are needed.
445451 // It is the union of the scopes on all three clients.
446452 const scopes : string [ ] = [ ] ;
@@ -486,37 +492,37 @@ export class Bigtable {
486492 BigtableClient : Object . assign (
487493 {
488494 servicePath : customEndpoint ? customEndpointBaseUrl : defaultBaseUrl ,
489- port : customEndpoint ? parseInt ( customEndpointPort , 10 ) : 443 ,
495+ port : customEndpoint ? Number ( customEndpointPort ) : 443 ,
490496 sslCreds : customEndpoint
491497 ? grpc . credentials . createInsecure ( )
492498 : undefined ,
493499 } ,
494500 options
495- ) ,
501+ ) as gax . ClientOptions ,
496502 BigtableInstanceAdminClient : Object . assign (
497503 {
498504 servicePath : customEndpoint
499505 ? customEndpointBaseUrl
500506 : defaultAdminBaseUrl ,
501- port : customEndpoint ? parseInt ( customEndpointPort , 10 ) : 443 ,
507+ port : customEndpoint ? Number ( customEndpointPort ) : 443 ,
502508 sslCreds : customEndpoint
503509 ? grpc . credentials . createInsecure ( )
504510 : undefined ,
505511 } ,
506512 options
507- ) ,
513+ ) as gax . ClientOptions ,
508514 BigtableTableAdminClient : Object . assign (
509515 {
510516 servicePath : customEndpoint
511517 ? customEndpointBaseUrl
512518 : defaultAdminBaseUrl ,
513- port : customEndpoint ? parseInt ( customEndpointPort , 10 ) : 443 ,
519+ port : customEndpoint ? Number ( customEndpointPort ) : 443 ,
514520 sslCreds : customEndpoint
515521 ? grpc . credentials . createInsecure ( )
516522 : undefined ,
517523 } ,
518524 options
519- ) ,
525+ ) as gax . ClientOptions ,
520526 } ;
521527
522528 this . api = { } ;
@@ -582,7 +588,7 @@ export class Bigtable {
582588 *
583589 * operation
584590 * .on('error', console.log)
585- * .on('complete', function() {
591+ * .on('complete', () => {
586592 * // The instance was created successfully.
587593 * });
588594 * };
@@ -621,17 +627,17 @@ export class Bigtable {
621627 const callback =
622628 typeof optionsOrCallback === 'function' ? optionsOrCallback : cb ;
623629
624- const reqOpts : any = {
630+ const reqOpts = {
625631 parent : this . projectName ,
626632 instanceId : id ,
627633 instance : {
628634 displayName : options . displayName || id ,
629635 labels : options . labels ,
630636 } ,
631- } ;
637+ } as google . bigtable . admin . v2 . CreateInstanceRequest ;
632638
633639 if ( options . type ) {
634- reqOpts . instance . type = Instance . getTypeType_ ( options . type ) ;
640+ reqOpts . instance ! . type = Instance . getTypeType_ ( options . type ) ;
635641 }
636642
637643 reqOpts . clusters = arrify ( options . clusters ! ) . reduce ( ( clusters , cluster ) => {
@@ -759,7 +765,9 @@ export class Bigtable {
759765 return new Instance ( this , name ) ;
760766 }
761767
768+ // tslint:disable-next-line no-any
762769 request < T = any > ( config ?: any ) : AbortableDuplex ;
770+ // tslint:disable-next-line no-any
763771 request < T = any > ( config ?: any , callback ?: RequestCallback < T > ) : void ;
764772 /**
765773 * Funnel all API requests through this method, to be sure we have a project ID.
@@ -770,6 +778,7 @@ export class Bigtable {
770778 * @param {object } config.reqOpts Request options.
771779 * @param {function } [callback] Callback function.
772780 */
781+ // tslint:disable-next-line no-any
773782 request < T = any > (
774783 config : RequestOptions ,
775784 callback ?: ( err : ServiceError | null , resp ?: T ) => void
@@ -790,16 +799,15 @@ export class Bigtable {
790799 let gaxClient = this . api [ config . client ] ;
791800 if ( ! gaxClient ) {
792801 // Lazily instantiate client.
793- gaxClient = new v2 [ config . client ] (
794- ( this . options [ config . client ] as { } ) as gax . ClientOptions
795- ) ;
802+ const clientOptions = this . options [ config . client ] ! ;
803+ gaxClient = new v2 [ config . client ] ( clientOptions ) ;
796804 this . api [ config . client ] = gaxClient ;
797805 }
798806 let reqOpts = extend ( true , { } , config . reqOpts ) ;
799807 if ( this . shouldReplaceProjectIdToken && projectId !== '{{projectId}}' ) {
800808 reqOpts = replaceProjectIdToken ( reqOpts , projectId ! ) ;
801809 }
802- const requestFn = ( gaxClient as any ) [ config . method ! ] . bind (
810+ const requestFn = gaxClient [ config . method ! ] . bind (
803811 gaxClient ,
804812 reqOpts ,
805813 config . gaxOpts
@@ -930,9 +938,10 @@ promisifyAll(Bigtable, {
930938 */
931939
932940// Allow creating a `Bigtable` instance without using the `new` keyword.
933- // eslint- disable-next-line no-class-assign
941+ // tslint: disable-next-line no-any
934942( Bigtable as any ) = new Proxy ( Bigtable , {
935943 apply ( target , thisArg , argumentsList ) {
944+ // tslint:disable-next-line no-any
936945 return new ( target as any ) ( ...argumentsList ) ;
937946 } ,
938947} ) ;
0 commit comments