Skip to content

feat(librarian/nodejs): add additional_protos support#5233

Merged
quirogas merged 10 commits intogoogleapis:mainfrom
quirogas:feat/issue-5208-extra-protos
Apr 11, 2026
Merged

feat(librarian/nodejs): add additional_protos support#5233
quirogas merged 10 commits intogoogleapis:mainfrom
quirogas:feat/issue-5208-extra-protos

Conversation

@quirogas
Copy link
Copy Markdown
Contributor

@quirogas quirogas commented Apr 8, 2026

Implement a robust mechanism for including additional proto dependencies during Node.js client generation. It introduces the additional_protos configuration field and implements a union logic with common resources.

Implementation Details

  • Added AdditionalProtos to the NodejsPackage and NodejsAPI config structs.
  • Default Behavior: Librarian automatically includes google/cloud/common_resources.proto by default for all Node.js APIs. This provides out-of-the-box support for common path templates without requiring manual configuration for most libraries.
  • Union Logic: Specifying additional_protos (at the package or API level) allows adding extra dependencies. These are appended to the default common_resources.proto and deduplicated.
  • Naming Consistency: Follows the pattern established in the Java generator for naming and YAML tags.

Verification

  • Verified against google-cloud-secretmanager, google-cloud-kms, and google-cloud-resourcemanager.
  • Functional parity achieved: projectPath and related helpers are correctly restored in the generated clients.
  • Unit tests added in internal/librarian/nodejs/generate_test.go covering 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 to protoc.

For #4404: Updates the Node.js generation logic to support these new configuration fields.

For #4413: The migrate tool should be updated to automatically detect proto_library_with_info dependencies from BUILD.bazel files and populate the additional_protos field in librarian.yaml.

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
@quirogas quirogas self-assigned this Apr 8, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread internal/librarian/nodejs/generate.go Outdated
Comment thread internal/config/language.go Outdated
Copy link
Copy Markdown
Contributor

@sofisl sofisl left a comment

Choose a reason for hiding this comment

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

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.

Comment thread internal/librarian/nodejs/generate.go Outdated
@quirogas quirogas changed the title feat(nodejs): add extra_protos support for Node.js generation feat(nodejs): add additional_protos support with default override Apr 10, 2026
@quirogas quirogas requested a review from sofisl April 10, 2026 18:11
@quirogas quirogas marked this pull request as ready for review April 10, 2026 18:11
@quirogas quirogas requested a review from a team as a code owner April 10, 2026 18:11
@quirogas quirogas enabled auto-merge (squash) April 10, 2026 18:59
Comment thread doc/config-schema.md Outdated
Comment thread doc/config-schema.md Outdated
Comment thread doc/config-schema.md Outdated
Comment thread doc/config-schema.md
@quirogas quirogas changed the title feat(nodejs): add additional_protos support with default override feat(nodejs): add additional_protos support Apr 11, 2026
@quirogas quirogas merged commit 69ec192 into googleapis:main Apr 11, 2026
18 checks passed
@quirogas quirogas changed the title feat(nodejs): add additional_protos support feat(librarian/nodejs): add additional_protos support Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nodejs: add support for proto_library_with_info macro functionality nodejs: generator removes path template helpers from client

2 participants