Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

Commit 2fc68ba

Browse files
build!: convert to typescript (#923)
1 parent 45d9880 commit 2fc68ba

63 files changed

Lines changed: 37311 additions & 49552 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

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+
}

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
node: [8, 10, 12, 13]
12+
node: [10, 12, 13]
1313
steps:
1414
- uses: actions/checkout@v2
1515
- uses: actions/setup-node@v1

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
**/*.log
22
**/node_modules
33
.coverage
4+
coverage
45
.nyc_output
56
docs/
67
out/
78
build/
89
system-test/secrets.js
910
system-test/*key.json
1011
*.lock
11-
.vscode
12-
**/package-lock.json
1312
.DS_Store
14-
google-cloud-logging-winston-*.tgz
15-
google-cloud-logging-bunyan-*.tgz
13+
package-lock.json
1614
__pycache__

.jsdoc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Google LLC
1+
// Copyright 2020 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,6 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
1518

1619
'use strict';
1720

@@ -37,7 +40,7 @@ module.exports = {
3740
includePattern: '\\.js$'
3841
},
3942
templates: {
40-
copyright: 'Copyright 2019 Google, LLC.',
43+
copyright: 'Copyright 2020 Google LLC',
4144
includeDate: false,
4245
sourceFiles: false,
4346
systemName: '@google-cloud/pubsub',

.mocharc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"enable-source-maps": true,
3+
"throw-deprecation": true,
4+
"timeout": 10000
5+
}

src/v1/doc/google/iam/v1/doc_iam_policy.js renamed to .prettierrc.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// https://www.apache.org/licenses/LICENSE-2.0
7+
// https://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// Note: this file is purely for documentation. Any contents are not expected
16-
// to be loaded as the JS file.
15+
module.exports = {
16+
...require('gts/.prettierrc.json')
17+
}

helperMethods.ts.tmpl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* This part will be added into src/v1/key_management_service_client.ts by synth.py.
3+
* KMS service requires IAM client for [setIamPolicy, getIamPolicy, testIamPerssion] methods.
4+
* But we don't support it now in micro-generators for rerouting one service to another and mix them in.
5+
* New feature request link: [https://github.com/googleapis/gapic-generator-typescript/issues/315]
6+
*
7+
* So this is manually written for providing methods to the KMS client.
8+
* IamClient is created for KMS client in the constructor using src/helper.ts.
9+
* [setIamPolicy, getIamPolicy, testIamPerssion] methods are created which is calling the corresponding methods from IamClient in `helper.ts`.
10+
*/
11+
12+
getIamPolicy(
13+
request: protos.google.iam.v1.GetIamPolicyRequest,
14+
options: gax.CallOptions,
15+
callback: protos.google.iam.v1.IAMPolicy.GetIamPolicyCallback
16+
) {
17+
return this._iamClient.getIamPolicy(request, options, callback);
18+
}
19+
setIamPolicy(
20+
request: protos.google.iam.v1.SetIamPolicyRequest,
21+
options: gax.CallOptions,
22+
callback: protos.google.iam.v1.IAMPolicy.SetIamPolicyCallback
23+
) {
24+
return this._iamClient.setIamPolicy(request, options, callback);
25+
}
26+
testIamPermissions(
27+
request: protos.google.iam.v1.TestIamPermissionsRequest,
28+
options: gax.CallOptions,
29+
callback?: protos.google.iam.v1.IAMPolicy.TestIamPermissionsCallback
30+
) {
31+
return this._iamClient.testIamPermissions(request, options, callback);
32+
}
33+
}

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"main": "./build/src/index.js",
1212
"types": "./build/src/index.d.ts",
1313
"files": [
14-
"build/proto",
1514
"build/protos",
1615
"build/src"
1716
],
@@ -30,19 +29,17 @@
3029
"scripts": {
3130
"presystem-test": "npm run compile",
3231
"system-test": "mocha build/system-test --timeout 600000",
33-
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
34-
"test": "c8 mocha build/test/*{,/*}.js",
35-
"lint": "eslint '**/*.js' && gts check",
32+
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
33+
"test": "c8 mocha build/test",
34+
"lint": "gts check",
3635
"predocs": "npm run compile",
3736
"docs": "jsdoc -c .jsdoc.js",
38-
"fix": "eslint --fix '**/*.js' && gts fix",
37+
"fix": "gts fix",
3938
"clean": "gts clean",
40-
"compile": "tsc -p . && cp -r src/v1 build/src/ && cp -r protos build/ && cp -r proto build/ && cp smoke-test/*.js build/system-test && cp test/*.js build/test",
41-
"prepare": "npm run compile",
39+
"compile": "tsc -p . && cp -r protos build/",
40+
"compile-protos": "compileProtos src",
41+
"prepare": "npm run compile-protos && npm run compile",
4242
"pretest": "npm run compile",
43-
"proto": "mkdirp proto && npm run proto:pubsub && npm run proto:iam",
44-
"proto:pubsub": "pbjs -t static-module -w commonjs -p protos google/pubsub/v1/pubsub.proto | pbts -o proto/pubsub.d.ts -",
45-
"proto:iam": "pbjs -t static-module -w commonjs -p protos google/iam/v1/iam_policy.proto | pbts -o proto/iam.d.ts -",
4643
"docs-test": "linkinator docs",
4744
"predocs-test": "npm run docs",
4845
"benchwrapper": "node bin/benchwrapper.js"
@@ -58,7 +55,7 @@
5855
"async-each": "^1.0.1",
5956
"extend": "^3.0.2",
6057
"google-auth-library": "^6.0.0",
61-
"google-gax": "^1.14.2",
58+
"google-gax": "^2.0.0",
6259
"is-stream-ended": "^0.1.4",
6360
"lodash.snakecase": "^4.1.1",
6461
"p-defer": "^3.0.0",
@@ -72,6 +69,7 @@
7269
"@types/mocha": "^7.0.0",
7370
"@types/mv": "^2.1.0",
7471
"@types/ncp": "^2.0.1",
72+
"@types/node": "^12.12.30",
7573
"@types/proxyquire": "^1.3.28",
7674
"@types/sinon": "^9.0.0",
7775
"@types/tmp": "^0.1.0",
@@ -92,12 +90,16 @@
9290
"mocha": "^7.0.0",
9391
"mv": "^2.1.1",
9492
"ncp": "^2.0.0",
93+
"null-loader": "^3.0.0",
9594
"prettier": "^1.18.2",
9695
"proxyquire": "^2.0.0",
9796
"sinon": "^9.0.0",
9897
"source-map-support": "^0.5.9",
98+
"ts-loader": "^6.2.1",
9999
"typescript": "3.6.4",
100100
"uuid": "^7.0.0",
101+
"webpack": "^4.42.0",
102+
"webpack-cli": "^3.3.11",
101103
"yargs": "^15.0.0"
102104
}
103105
}

0 commit comments

Comments
 (0)