Skip to content

Commit 07081d2

Browse files
alexander-fensterGautamSharda
authored andcommitted
feat!: drop node8 support, support for async iterators (#682)
1 parent 476a913 commit 07081d2

36 files changed

Lines changed: 10186 additions & 4571 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./node_modules/gts"
3+
}

handwritten/bigtable/.eslintrc.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

handwritten/bigtable/.prettierrc

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
module.exports = {
16+
...require('gts/.prettierrc.json')
17+
}

handwritten/bigtable/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"dot-prop": "^5.0.0",
5252
"escape-string-regexp": "^2.0.0",
5353
"extend": "^3.0.2",
54-
"google-gax": "^1.14.2",
54+
"google-gax": "^2.0.1",
5555
"is": "^3.0.1",
5656
"is-utf8": "^0.2.1",
5757
"lodash.snakecase": "^4.1.1",
@@ -63,6 +63,7 @@
6363
"through2": "^3.0.0"
6464
},
6565
"devDependencies": {
66+
"@grpc/grpc-js": "^0.7.5",
6667
"@types/escape-string-regexp": "^1.0.0",
6768
"@types/extend": "^3.0.1",
6869
"@types/is": "0.0.21",
@@ -82,7 +83,8 @@
8283
"eslint-config-prettier": "^6.10.0",
8384
"eslint-plugin-node": "^11.0.0",
8485
"eslint-plugin-prettier": "^3.1.2",
85-
"gts": "^1.1.2",
86+
"google-auth-library": "^6.0.0",
87+
"gts": "2.0.0-alpha.9",
8688
"jsdoc": "^3.6.3",
8789
"jsdoc-fresh": "^1.0.2",
8890
"jsdoc-region-tag": "^1.0.4",
@@ -97,9 +99,9 @@
9799
"power-assert": "^1.6.1",
98100
"prettier": "^1.19.1",
99101
"proxyquire": "^2.0.0",
100-
"sinon": "^9.0.0",
102+
"sinon": "^9.0.1",
101103
"ts-loader": "^6.2.1",
102-
"typescript": "^3.7.0",
104+
"typescript": "^3.8.3",
103105
"uuid": "^7.0.0",
104106
"webpack": "^4.42.0",
105107
"webpack-cli": "^3.3.11"

handwritten/bigtable/src/filter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import arrify = require('arrify');
1616
import * as escapeStringRegexp from 'escape-string-regexp';
1717
import * as is from 'is';
18+
// eslint-disable-next-line @typescript-eslint/no-var-requires
1819
const isUtf8 = require('is-utf8');
1920
import {Mutation} from './mutation';
2021

@@ -47,7 +48,7 @@ export interface Time {
4748
end: Date | number;
4849
}
4950

50-
// tslint:disable-next-line no-any
51+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5152
export type RawFilter = any;
5253

5354
export interface Condition {
@@ -268,7 +269,7 @@ export class Filter {
268269
[index: string]: Function;
269270
}
270271
const filter = new Filter();
271-
// tslint:disable-next-line no-any
272+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
272273
arrify(filters).forEach((filterObj: any) => {
273274
const key = Object.keys(filterObj)[0];
274275
if (typeof ((filter as {}) as Fn)[key] !== 'function') {
@@ -448,7 +449,7 @@ export class Filter {
448449
}
449450

450451
if (col.start || col.end) {
451-
// tslint:disable-next-line no-any
452+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
452453
const range: any = Filter.createRange(col.start!, col.end!, 'Qualifier');
453454

454455
range.familyName = col.family;

handwritten/bigtable/src/index.ts

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/**
16-
* @namespace google
17-
*/
18-
/**
19-
* @namespace google.bigtable
20-
*/
21-
/**
22-
* @namespace google.bigtable.v2
23-
*/
24-
/**
25-
* @namespace google.bigtable.admin.v2
26-
*/
27-
/**
28-
* @namespace google.iam.v1
29-
*/
30-
/**
31-
* @namespace google.rpc
32-
*/
33-
/**
34-
* @namespace google.protobuf
35-
*/
36-
/**
37-
* @namespace google.type
38-
*/
39-
/**
40-
* @namespace google.longrunning
41-
*/
4215
import {replaceProjectIdToken} from '@google-cloud/projectify';
4316
import {promisifyAll} from '@google-cloud/promisify';
4417
import arrify = require('arrify');
@@ -64,9 +37,12 @@ import {google} from '../protos/protos';
6437
import {ServiceError} from '@grpc/grpc-js';
6538
import * as v2 from './v2';
6639

40+
// eslint-disable-next-line @typescript-eslint/no-var-requires
6741
const retryRequest = require('retry-request');
42+
// eslint-disable-next-line @typescript-eslint/no-var-requires
6843
const streamEvents = require('stream-events');
6944

45+
// eslint-disable-next-line @typescript-eslint/no-var-requires
7046
const PKG = require('../../package.json');
7147

7248
const {grpc} = new gax.GrpcClient();
@@ -439,11 +415,8 @@ export class Bigtable {
439415
appProfileId?: string;
440416
projectName: string;
441417
shouldReplaceProjectIdToken: boolean;
442-
// tslint:disable-next-line variable-name
443418
static AppProfile: AppProfile;
444-
// tslint:disable-next-line variable-name
445419
static Instance: Instance;
446-
// tslint:disable-next-line variable-name
447420
static Cluster: Cluster;
448421

449422
constructor(options: BigtableOptions = {}) {
@@ -771,9 +744,9 @@ export class Bigtable {
771744
return new Instance(this, name);
772745
}
773746

774-
// tslint:disable-next-line no-any
747+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
775748
request<T = any>(config?: any): AbortableDuplex;
776-
// tslint:disable-next-line no-any
749+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
777750
request<T = any>(config?: any, callback?: RequestCallback<T>): void;
778751
/**
779752
* Funnel all API requests through this method, to be sure we have a project ID.
@@ -784,7 +757,7 @@ export class Bigtable {
784757
* @param {object} config.reqOpts Request options.
785758
* @param {function} [callback] Callback function.
786759
*/
787-
// tslint:disable-next-line no-any
760+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
788761
request<T = any>(
789762
config: RequestOptions,
790763
callback?: (err: ServiceError | null, resp?: T) => void
@@ -813,7 +786,7 @@ export class Bigtable {
813786
if (this.shouldReplaceProjectIdToken && projectId !== '{{projectId}}') {
814787
reqOpts = replaceProjectIdToken(reqOpts, projectId!);
815788
}
816-
// tslint:disable-next-line:no-any
789+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
817790
const requestFn = (gaxClient as any)[config.method!].bind(
818791
gaxClient,
819792
reqOpts,
@@ -945,14 +918,13 @@ promisifyAll(Bigtable, {
945918
*/
946919

947920
// Allow creating a `Bigtable` instance without using the `new` keyword.
948-
// tslint:disable-next-line no-any
921+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
949922
(Bigtable as any) = new Proxy(Bigtable, {
950923
apply(target, thisArg, argumentsList) {
951-
// tslint:disable-next-line no-any
924+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
952925
return new (target as any)(...argumentsList);
953926
},
954927
});
955-
956928
/**
957929
* The default export of the `@google-cloud/bigtable` package is the
958930
* {@link Bigtable} class.
@@ -986,4 +958,6 @@ promisifyAll(Bigtable, {
986958
module.exports = Bigtable;
987959
module.exports.v2 = v2;
988960
module.exports.Bigtable = Bigtable;
961+
962+
export {v2};
989963
export {protos};

handwritten/bigtable/src/instance.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export interface InstanceOptions {
8989
* No more than 64 labels can be associated with a given resource.
9090
* Keys and values must both be under 128 bytes.
9191
*/
92-
// tslint:disable-next-line no-any
92+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9393
labels?: {[index: string]: any};
9494

9595
type?: 'production' | 'development';
@@ -478,15 +478,15 @@ Please use the format 'my-instance' or '${bigtable.projectName}/instances/my-ins
478478
}
479479

480480
if (options.families) {
481-
// tslint:disable-next-line no-any
481+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
482482
const columnFamilies = (options.families as any[]).reduce(
483483
(families, family) => {
484484
if (typeof family === 'string') {
485485
family = {
486486
name: family,
487487
};
488488
}
489-
// tslint:disable-next-line no-any
489+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
490490
const columnFamily: any = (families[family.name] = {});
491491
if (family.rule) {
492492
columnFamily.gcRule = Family.formatRule_(family.rule);

handwritten/bigtable/src/mutation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type IMutateRowRequest = btTypes.bigtable.v2.IMutateRowRequest;
2323
export type ISetCell = btTypes.bigtable.v2.Mutation.ISetCell;
2424

2525
export type Bytes = string | Buffer;
26-
// tslint:disable-next-line:no-any
26+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2727
export type Data = any;
2828
export interface JsonObj {
2929
[k: string]: string | JsonObj;
@@ -111,7 +111,7 @@ export class Mutation {
111111
): Buffer | Value | string {
112112
const buf = bytes instanceof Buffer ? bytes : Buffer.from(bytes, 'base64');
113113
if (options && options.isPossibleNumber && buf.length === 8) {
114-
// tslint:disable-next-line no-any
114+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
115115
const num = Long.fromBytes(buf as any).toNumber();
116116

117117
if (Number.isSafeInteger(num)) {
@@ -209,7 +209,7 @@ export class Mutation {
209209
const mutations: SetCellObj[] = [];
210210

211211
Object.keys(data).forEach(familyName => {
212-
// tslint:disable-next-line no-any
212+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
213213
const family = (data as any)[familyName];
214214

215215
Object.keys(family).forEach(cellName => {

handwritten/bigtable/src/row.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414

1515
import {promisifyAll} from '@google-cloud/promisify';
1616
import arrify = require('arrify');
17+
// eslint-disable-next-line @typescript-eslint/no-var-requires
1718
const dotProp = require('dot-prop');
1819
import {Filter, RawFilter} from './filter';
19-
import {
20-
Mutation,
21-
ConvertFromBytesUserOptions,
22-
Bytes,
23-
IMutation,
24-
} from './mutation';
20+
import {Mutation, ConvertFromBytesUserOptions, Bytes} from './mutation';
2521
import {Bigtable} from '.';
2622
import {
2723
Table,
@@ -159,7 +155,7 @@ export class Row {
159155
bigtable: Bigtable;
160156
table: Table;
161157
id: string;
162-
// tslint:disable-next-line no-any
158+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
163159
data: any;
164160
key?: string;
165161
metadata?: {};
@@ -258,7 +254,7 @@ export class Row {
258254
}
259255

260256
return row;
261-
// tslint:disable-next-line no-any
257+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
262258
}, {} as any);
263259

264260
return rows;
@@ -422,7 +418,7 @@ export class Row {
422418

423419
rules = arrify(rules).map(rule => {
424420
const column = Mutation.parseColumnName(rule.column);
425-
// tslint:disable-next-line no-any
421+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
426422
const ruleData: any = {
427423
familyName: column.family,
428424
columnQualifier: Mutation.convertToBytes(column.qualifier!),
@@ -656,18 +652,18 @@ export class Row {
656652
}
657653

658654
get(options?: GetRowOptions): Promise<GetRowResponse<Row>>;
659-
// tslint:disable-next-line no-any
655+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
660656
get<T = any>(
661657
columns: string[],
662658
options?: GetRowOptions
663659
): Promise<GetRowResponse<T>>;
664-
// tslint:disable-next-line no-any
660+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
665661
get<T = any>(
666662
columns: string[],
667663
options: GetRowOptions,
668664
callback: GetRowCallback<T>
669665
): void;
670-
// tslint:disable-next-line no-any
666+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
671667
get<T = any>(columns: string[], callback: GetRowCallback<T>): void;
672668
get(callback: GetRowCallback<Row>): void;
673669
get(options: GetRowOptions, callback: GetRowCallback<Row>): void;
@@ -688,7 +684,7 @@ export class Row {
688684
* @example <caption>include:samples/document-snippets/row.js</caption>
689685
* region_tag:bigtable_get_row
690686
*/
691-
// tslint:disable-next-line no-any
687+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
692688
get<T = any | Row>(
693689
columnsOrOptionsOrCallback?: string[] | GetRowOptions | GetRowCallback<T>,
694690
optionsOrCallback?: GetRowOptions | GetRowCallback<T>,
@@ -717,7 +713,7 @@ export class Row {
717713
// if there is column filter
718714
if (columns.length) {
719715
const filters = columns.map(Mutation.parseColumnName).map(column => {
720-
// tslint:disable-next-line no-any
716+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
721717
const colmFilters: any = [{family: column.family}];
722718
if (column.qualifier) {
723719
colmFilters.push({column: column.qualifier});

0 commit comments

Comments
 (0)