Skip to content

Commit 5251604

Browse files
JustinBeckwiththiyaguk09
authored andcommitted
Split usage of common module (googleapis#297)
1 parent 0e5a9ca commit 5251604

18 files changed

Lines changed: 68 additions & 103 deletions

handwritten/bigtable/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@
5353
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
5454
"lint": "eslint src/ samples/ system-test/ test/",
5555
"prettier": "prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js",
56-
"publish-module": "node ../../scripts/publish.js bigtable",
5756
"system-test": "mocha system-test/*.js --timeout 600000",
5857
"snippet-test": "mocha samples/document-snippets/test.js --timeout 600000"
5958
},
6059
"dependencies": {
6160
"@google-cloud/common-grpc": "^0.7.1",
61+
"@google-cloud/paginator": "^0.1.0",
62+
"@google-cloud/projectify": "^0.3.0",
63+
"@google-cloud/promisify": "^0.3.0",
6264
"arrify": "^1.0.0",
6365
"concat-stream": "^1.5.0",
64-
"create-error-class": "^3.0.2",
6566
"dot-prop": "^4.2.0",
6667
"escape-string-regexp": "^1.0.5",
6768
"extend": "^3.0.0",

handwritten/bigtable/src/app-profile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
const common = require('@google-cloud/common-grpc');
17+
const {promisifyAll} = require('@google-cloud/promisify');
1818
const is = require('is');
1919
const snakeCase = require('lodash.snakecase');
2020

@@ -400,7 +400,7 @@ Please use the format 'my-app-profile' or '${
400400
* All async methods (except for streams) will return a Promise in the event
401401
* that a callback is omitted.
402402
*/
403-
common.util.promisifyAll(AppProfile);
403+
promisifyAll(AppProfile);
404404

405405
/**
406406
* Reference to the {@link AppProfile} class.

handwritten/bigtable/src/chunktransformer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
const Mutation = require('./mutation');
17-
const stream = require('stream');
18-
const Transform = stream.Transform;
17+
const {Transform} = require('stream');
1918

2019
class TransformError extends Error {
2120
constructor(props) {

handwritten/bigtable/src/cluster.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
const common = require('@google-cloud/common-grpc');
17+
const {promisifyAll} = require('@google-cloud/promisify');
1818
const is = require('is');
1919

2020
/**
@@ -400,7 +400,7 @@ Please use the format 'my-cluster' or '${instance.name}/clusters/my-cluster'.`
400400
* All async methods (except for streams) will return a Promise in the event
401401
* that a callback is omitted.
402402
*/
403-
common.util.promisifyAll(Cluster);
403+
promisifyAll(Cluster);
404404

405405
/**
406406
* Reference to the {@link Cluster} class.

handwritten/bigtable/src/family.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
const common = require('@google-cloud/common-grpc');
17+
const {promisifyAll} = require('@google-cloud/promisify');
1818
const is = require('is');
1919

2020
/**
@@ -436,7 +436,7 @@ Please use the format 'follows' or '${table.name}/columnFamilies/my-family'.`
436436
* All async methods (except for streams) will return a Promise in the event
437437
* that a callback is omitted.
438438
*/
439-
common.util.promisifyAll(Family);
439+
promisifyAll(Family);
440440

441441
module.exports = Family;
442442
module.exports.FamilyError = FamilyError;

handwritten/bigtable/src/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
*/
1616

1717
const arrify = require('arrify');
18-
const common = require('@google-cloud/common-grpc');
18+
const {replaceProjectIdToken} = require('@google-cloud/projectify');
19+
const {promisifyAll} = require('@google-cloud/promisify');
1920
const extend = require('extend');
20-
const GrpcService = require('@google-cloud/common-grpc').Service;
21+
const {Service} = require('@google-cloud/common-grpc');
2122
const {GoogleAuth} = require('google-auth-library');
2223
const gax = require('google-gax');
2324
const grpc = new gax.GrpcClient().grpc;
@@ -337,7 +338,7 @@ const v2 = require('./v2');
337338
*/
338339
class Bigtable {
339340
constructor(options) {
340-
options = common.util.normalizeArguments(this, options);
341+
options = options || {};
341342

342343
// Determine what scopes are needed.
343344
// It is the union of the scopes on all three clients.
@@ -654,7 +655,7 @@ class Bigtable {
654655
let reqOpts = extend(true, {}, config.reqOpts);
655656

656657
if (this.shouldReplaceProjectIdToken && projectId !== '{{projectId}}') {
657-
reqOpts = common.util.replaceProjectIdToken(reqOpts, projectId);
658+
reqOpts = replaceProjectIdToken(reqOpts, projectId);
658659
}
659660

660661
const requestFn = gaxClient[config.method].bind(
@@ -708,7 +709,7 @@ class Bigtable {
708709
currentRetryAttempt: 0,
709710
noResponseRetries: 0,
710711
objectMode: true,
711-
shouldRetryFn: GrpcService.shouldRetryRequest_,
712+
shouldRetryFn: Service.shouldRetryRequest_,
712713
request() {
713714
gaxStream = requestFn();
714715
return gaxStream;
@@ -762,7 +763,7 @@ class Bigtable {
762763
* All async methods (except for streams) will return a Promise in the event
763764
* that a callback is omitted.
764765
*/
765-
common.util.promisifyAll(Bigtable, {
766+
promisifyAll(Bigtable, {
766767
exclude: ['instance', 'operation', 'request'],
767768
});
768769

handwritten/bigtable/src/instance.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
const common = require('@google-cloud/common-grpc');
17+
const {paginator} = require('@google-cloud/paginator');
18+
const {promisifyAll} = require('@google-cloud/promisify');
1819
const extend = require('extend');
1920
const is = require('is');
2021
const snakeCase = require('lodash.snakecase');
@@ -749,20 +750,20 @@ Please use the format 'my-instance' or '${
749750
* this.end();
750751
* });
751752
*/
752-
Instance.prototype.getTablesStream = common.paginator.streamify('getTables');
753+
Instance.prototype.getTablesStream = paginator.streamify('getTables');
753754

754755
/*! Developer Documentation
755756
*
756757
* These methods can be auto-paginated.
757758
*/
758-
common.paginator.extend(Instance, ['getTables']);
759+
paginator.extend(Instance, ['getTables']);
759760

760761
/*! Developer Documentation
761762
*
762763
* All async methods (except for streams) will return a Promise in the event
763764
* that a callback is omitted.
764765
*/
765-
common.util.promisifyAll(Instance, {
766+
promisifyAll(Instance, {
766767
exclude: ['appProfile', 'cluster', 'table'],
767768
});
768769

handwritten/bigtable/src/row.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
const arrify = require('arrify');
18-
const common = require('@google-cloud/common-grpc');
18+
const {promisifyAll} = require('@google-cloud/promisify');
1919
const dotProp = require('dot-prop');
2020
const extend = require('extend');
2121
const flatten = require('lodash.flatten');
@@ -921,7 +921,7 @@ class Row {
921921
* All async methods (except for streams) will return a Promise in the event
922922
* that a callback is omitted.
923923
*/
924-
common.util.promisifyAll(Row);
924+
promisifyAll(Row);
925925

926926
module.exports = Row;
927927
module.exports.RowError = RowError;

handwritten/bigtable/src/table.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
const arrify = require('arrify');
1818
const common = require('@google-cloud/common-grpc');
19+
const {promisifyAll} = require('@google-cloud/promisify');
1920
const concat = require('concat-stream');
2021
const flatten = require('lodash.flatten');
2122
const is = require('is');
@@ -1513,7 +1514,7 @@ Table.VIEWS = {
15131514
* All async methods (except for streams) will return a Promise in the event
15141515
* that a callback is omitted.
15151516
*/
1516-
common.util.promisifyAll(Table, {
1517+
promisifyAll(Table, {
15171518
exclude: ['family', 'row'],
15181519
});
15191520

handwritten/bigtable/synth.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,15 @@
66
logging.basicConfig(level=logging.DEBUG)
77

88
gapic = gcp.GAPICGenerator()
9-
common_templates = gcp.CommonTemplates()
10-
119
v2_library = gapic.node_library(
1210
'bigtable', 'v2', config_path='/google/bigtable/artman_bigtable.yaml')
13-
14-
# Copy all files except for 'README.md' and 'package.json'
1511
s.copy(
1612
v2_library,
1713
excludes=['package.json', 'README.md', 'src/index.js', 'src/v2/index.js'])
1814

19-
templates = common_templates.node_library(
20-
package_name="@google-cloud/bigtable",
21-
repo_name="googleapis/nodejs-bigtable")
15+
common_templates = gcp.CommonTemplates()
16+
templates = common_templates.node_library()
2217
s.copy(templates)
2318

24-
#
25-
# Node.js specific cleanup
26-
#
2719
subprocess.run(['npm', 'install'])
2820
subprocess.run(['npm', 'run', 'prettier'])
29-
subprocess.run(['npm', 'run', 'lint'])

0 commit comments

Comments
 (0)