feat(librarian/nodejs): add additional_protos support#5233
feat(librarian/nodejs): add additional_protos support#5233quirogas merged 10 commits intogoogleapis:mainfrom
Conversation
Implement a configurable way to include additional proto dependencies during GAPIC generation. This mirrors the behavior of Bazel's proto_library_with_info macro. Specifically: - Add NodejsAPI struct to manage per-API configuration. - Add ExtraProtos field to NodejsPackage. - Automatically include google/cloud/common_resources.proto by default for Node.js APIs to ensure path helper methods (like projectPath) are generated. Fixes googleapis#5208
There was a problem hiding this comment.
Code Review
This pull request enables Node.js-specific API configurations, allowing for the inclusion of extra proto files during client library generation. It adds a NodejsAPIs field to the configuration and a resolution helper that defaults to common_resources.proto. Feedback suggests appending user-provided protos to the default list rather than overwriting it, ensuring that essential resources for path helper methods are always preserved.
There was a problem hiding this comment.
generally speaking one thing I'm not super clear on in Librarian is how it actually will get rid of Bazel files. But regardless, I think some test you want to set up is something to confirm that those necessary protos specified in the BUILD.bazel are actually passed in correctly. (maybe that's in another PR I assume)?
Not sure if this is more generally helpful, but this is what I mean by those extra necessary protos: cl/582493526. When I added compileProtos to the generation step (techncially outside of the generator, running in a wrapper script), I had to specify a bunch of these protos to actually get the code to run.
…eat/issue-5208-extra-protos
Run go generate ./... to regenerate the configuration schema documentation with the newly added AdditionalProtos and SkipDefaultAdditionalProtos fields for Node.js APIs.
Implement a robust mechanism for including additional proto dependencies during Node.js client generation. It introduces the
additional_protosconfiguration field and implements a union logic with common resources.Implementation Details
AdditionalProtosto theNodejsPackageandNodejsAPIconfig structs.google/cloud/common_resources.protoby default for all Node.js APIs. This provides out-of-the-box support for common path templates without requiring manual configuration for most libraries.additional_protos(at the package or API level) allows adding extra dependencies. These are appended to the defaultcommon_resources.protoand deduplicated.Verification
google-cloud-secretmanager,google-cloud-kms, andgoogle-cloud-resourcemanager.projectPathand related helpers are correctly restored in the generated clients.internal/librarian/nodejs/generate_test.gocovering default, hierarchical union, and deduplication scenarios.Fix #5208: Provides the necessary infrastructure to include
google/cloud/common_resources.proto, which contains common path template definitions.Fix #4744: Directly resolves the problem where the Node.js generator removes path template helpers (like
projectPath) by ensuring the required resource definitions are available toprotoc.For #4404: Updates the Node.js generation logic to support these new configuration fields.
For #4413: The
migratetool should be updated to automatically detectproto_library_with_infodependencies fromBUILD.bazelfiles and populate theadditional_protosfield inlibrarian.yaml.