Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: convert Gapic client to TypeScript #805

Merged
merged 10 commits into from
Dec 15, 2019
Merged

Conversation

alexander-fenster
Copy link
Contributor

@alexander-fenster alexander-fenster commented Dec 6, 2019

Converting the auto-generated parts of the library to TypeScript using the new https://github.com/googleapis/gapic-generator-typescript.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 6, 2019
"total_timeout_millis": 600000
}
},
"methods": {
"GetDocument": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_codes_name": "d_e_a_d_l_i_n_e_e_x_c_e_e_d_e_d_i_n_t_e_r_n_a_l_u_n_a_v_a_i_l_a_b_l_e",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a scary auto-generated name, looks like a bug - I'll figure out

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,17 +1,3 @@
// Copyright 2019 Google LLC
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the license added manually? I just used the update script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I wonder if it was added later when we migrated to the new Copyright header?

@@ -50,6 +50,14 @@ mkdir -p "${PROTOS_DIR}/google/firestore/v1"
cp googleapis/google/firestore/v1/*.proto \
"${PROTOS_DIR}/google/firestore/v1/"

mkdir -p "${PROTOS_DIR}/google/firestore/v1beta1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we need all the protos there.

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAY! Getting close to .close().

Thank you so much.

@@ -1,17 +1,3 @@
// Copyright 2019 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I wonder if it was added later when we migrated to the new Copyright header?

dev/protos/firestore_proto_api.js Outdated Show resolved Hide resolved
},
"nested": {
"Index": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, would the clients load faster if we split Admin/Non-Admin Protos?

const version = require('../../../package.json').version;

/**
* Operations are created by service `FirestoreAdmin`, but are accessed via
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Leading spaces.

dev/src/v1/firestore_admin_client_config.json Outdated Show resolved Hide resolved
it('has apiEndpoint', () => {
const apiEndpoint = firestoreModule.v1.FirestoreClient.apiEndpoint;
assert(apiEndpoint);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Keep empty lines (again, don't fix before merging)


'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be interesting to know if the old system tests pass against the new client. Did you test that by any chance?


# Fix dropping of google-cloud-resource-header
# See: https://github.com/googleapis/nodejs-firestore/pull/375
s.replace(
"dev/src/v1beta1/firestore_client.js",
"dev/src/v1beta1/firestore_client.ts",
"return this\._innerApiCalls\.listen\(options\);",
"return this._innerApiCalls.listen({}, options);",
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian Dec 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed (or rather: does the original bug still exist in the TS generated client?). It would seem that this should now be caught by the type system.

tsconfig.json Show resolved Hide resolved
tsconfig.json Show resolved Hide resolved
Copy link
Contributor Author

@alexander-fenster alexander-fenster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @schmidt-sebastian - I'll make more changes on Friday :)

We need to also include the field_definition and client protos
@codecov
Copy link

codecov bot commented Dec 6, 2019

Codecov Report

Merging #805 into master will increase coverage by 16.12%.
The diff coverage is 66.26%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #805       +/-   ##
===========================================
+ Coverage   74.24%   90.36%   +16.12%     
===========================================
  Files          50       25       -25     
  Lines        2904     2814       -90     
  Branches      462      707      +245     
===========================================
+ Hits         2156     2543      +387     
+ Misses        695      118      -577     
- Partials       53      153      +100
Impacted Files Coverage Δ
dev/src/index.ts 96.96% <ø> (ø) ⬆️
dev/src/timestamp.ts 92.59% <ø> (ø) ⬆️
dev/src/field-value.ts 95% <ø> (ø) ⬆️
dev/src/document.ts 96.15% <ø> (ø) ⬆️
dev/src/reference.ts 99.03% <ø> (ø) ⬆️
dev/src/convert.ts 92.4% <ø> (ø) ⬆️
dev/src/order.ts 95.19% <ø> (ø) ⬆️
dev/src/write-batch.ts 98.63% <ø> (ø) ⬆️
dev/src/watch.ts 95.98% <ø> (ø) ⬆️
dev/src/geo-point.ts 91.66% <ø> (ø) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9cab55...19adbc4. Read the comment docs.

@schmidt-sebastian
Copy link
Contributor

The system tests should pass once googleapis/gapic-generator-typescript#173 is merged and released.

@alexander-fenster alexander-fenster added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 14, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 14, 2019
@alexander-fenster
Copy link
Contributor Author

I'm guessing we first need to update synth.py to make changes for your latest fixes, then run the generator again.

@schmidt-sebastian
Copy link
Contributor

Re-ran synthool and pushed changes. The only remaining blockers (in my opinion) are the setting for initial_rpc_timeout_millis and max_rpc_timeout_millis. Should we drop them?

@schmidt-sebastian
Copy link
Contributor

Updated all the dependencies since the CI requires a newer version of gts than in package.json and the generated clients require a newer version of Google Gax (for gax.OperationsClient).

@alexander-fenster
Copy link
Contributor Author

alexander-fenster commented Dec 15, 2019

Dropping of initial_rpc_timeout_millis and others will be done in gax (the exported type requires those unused parameters to be set). I will first remove them from there, then from the generator. All generated libraries will be updated within the nightly synthtool run.

I think we are good to go here! I suggest we treat this PR as a breaking change just in case (feel free to merge the PR then), otherwise, if you think it's just a minor, remove ! from the PR title before merging :) It's up to you.

Upd. The parameters are actually used but will be dropped soon.

@alexander-fenster
Copy link
Contributor Author

googleapis/gapic-generator-typescript#175 will reset the parameters to 60000. We can merge now (this change will come within a nightly synthtool run) or wait for this change to make its way into the Docker image (will happen on Monday).

@schmidt-sebastian schmidt-sebastian changed the title feat!: convert to TypeScript feat!: convert Gapic client to TypeScript Dec 15, 2019
@schmidt-sebastian schmidt-sebastian merged commit 5000b2d into master Dec 15, 2019
@release-please release-please bot mentioned this pull request Dec 15, 2019
@schmidt-sebastian schmidt-sebastian deleted the typescript branch January 3, 2020 00:33
@willbattel
Copy link

willbattel commented Jun 4, 2020

This PR is linked in the v3.0.0 release notes as a breaking change. Is there anything that users of this library need to change to stay compliant? It looks mostly internal as far as I can tell.

@schmidt-sebastian
Copy link
Contributor

We bumped the major version because of the risk with this PR. We are not aware of any specific breakages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants