Skip to content

feat(spanner): split GAPIC from the spanner handwritten package#8931

Closed
quirogas wants to merge 3 commits into
googleapis:mainfrom
quirogas:feat/disentangle-spanner-handwritten
Closed

feat(spanner): split GAPIC from the spanner handwritten package#8931
quirogas wants to merge 3 commits into
googleapis:mainfrom
quirogas:feat/disentangle-spanner-handwritten

Conversation

@quirogas

Copy link
Copy Markdown
Contributor

Decouple the handwritten Spanner wrapper from the auto-generated GAPIC client layer by importing a standalone version of the GAPIC library. Standalone -api packages are now generated and maintained independently.

  • Removed embedded GAPIC generated code (src/v1/) and OwlBot files (owlbot.py, .OwlBot.yaml).
  • Added dependency on standalone @google-cloud/spanner-api (^0.2.0).
  • Re-exported v1, top-level sub-clients (SpannerClient, DatabaseAdminClient, InstanceAdminClient, SpannerExecutorProxyClient), and protos from @google-cloud/spanner- api.
  • Resolved protobufjs status definition loading in mock server test utilities.

Internal: b/531797111

@quirogas quirogas self-assigned this Jul 21, 2026
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Jul 21, 2026

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

Copy link
Copy Markdown
Contributor

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 replaces local proto files and generated clients with the external '@google-cloud/spanner-api' package, updating import paths across the codebase, removing obsolete generator scripts, and updating package dependencies. The review feedback suggests importing 'protos' directly from the public entry point of '@google-cloud/spanner-api' instead of deep-importing, simplifying the client re-exports in 'src/index.ts', and using a cleaner direct require path for 'status.json' from 'google-gax' in the mock server tests.

* Reference to {@link v1.SpannerClient}
*/
import * as protos from '../protos/protos';
import * as protos from '@google-cloud/spanner-api/build/protos/protos';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of deep-importing from the internal build/ directory of @google-cloud/spanner-api, you can import protos directly from the public entry point of the package. This is safer, more maintainable, and avoids potential module resolution issues if the package's internal structure changes or if strict package exports are enforced.

Suggested change
import * as protos from '@google-cloud/spanner-api/build/protos/protos';
import {protos} from '@google-cloud/spanner-api';

Comment on lines +2464 to +2470
const DatabaseAdminClient = v1.DatabaseAdminClient;
type DatabaseAdminClient = v1.DatabaseAdminClient;
const InstanceAdminClient = v1.InstanceAdminClient;
type InstanceAdminClient = v1.InstanceAdminClient;
const SpannerClient = v1.SpannerClient;
type SpannerClient = v1.SpannerClient;
export { DatabaseAdminClient, InstanceAdminClient, SpannerClient };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

These lines are highly verbose and redundant. In TypeScript, you can directly re-export both the values and types of these clients from @google-cloud/spanner-api in a single statement. Additionally, this ensures that SpannerExecutorProxyClient is also re-exported at the top level, as mentioned in the pull request description.

Suggested change
const DatabaseAdminClient = v1.DatabaseAdminClient;
type DatabaseAdminClient = v1.DatabaseAdminClient;
const InstanceAdminClient = v1.InstanceAdminClient;
type InstanceAdminClient = v1.InstanceAdminClient;
const SpannerClient = v1.SpannerClient;
type SpannerClient = v1.SpannerClient;
export { DatabaseAdminClient, InstanceAdminClient, SpannerClient };
export { DatabaseAdminClient, InstanceAdminClient, SpannerClient, SpannerExecutorProxyClient } from '@google-cloud/spanner-api';

Comment on lines +26 to +28
const protobufjs = require('protobufjs');
const statusProtoJson = require(path.join(path.dirname(require.resolve('google-gax')), '../protos/status.json'));
const RetryInfo: any = protobufjs.Root.fromJSON(statusProtoJson).lookupType('google.rpc.RetryInfo');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of using a fragile combination of require.resolve, path.dirname, and path.join to locate status.json inside google-gax, you can require it directly as 'google-gax/protos/status.json'. This is much cleaner, more readable, and less prone to breaking if the internal file structure of google-gax changes.

Suggested change
const protobufjs = require('protobufjs');
const statusProtoJson = require(path.join(path.dirname(require.resolve('google-gax')), '../protos/status.json'));
const RetryInfo: any = protobufjs.Root.fromJSON(statusProtoJson).lookupType('google.rpc.RetryInfo');
const protobufjs = require('protobufjs');
const statusProtoJson = require('google-gax/protos/status.json');
const RetryInfo: any = protobufjs.Root.fromJSON(statusProtoJson).lookupType('google.rpc.RetryInfo');

@feywind

feywind commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Closing this one as a dup for #8927, integrated some bits of it!

@feywind feywind closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants