Skip to content

feat(firestore): decouple handwritten sdk wrapper from embedded gapic clients - #8928

Open
quirogas wants to merge 15 commits into
googleapis:mainfrom
quirogas:feat/disentangle-firestore-handwritten
Open

feat(firestore): decouple handwritten sdk wrapper from embedded gapic clients#8928
quirogas wants to merge 15 commits into
googleapis:mainfrom
quirogas:feat/disentangle-firestore-handwritten

Conversation

@quirogas

@quirogas quirogas commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Decouple the handwritten Firestore SDK wrapper from embedded GAPIC client implementations by transitioning to the standalone @google-cloud/firestore-api package. Standalone -api packages are now generated and versioned independently.

Summary of Changes

  • GAPIC Dependency: Adds runtime dependency on standalone @google-cloud/firestore-api (^0.2.0).
  • Runtime Proto Delegation: Replaces static compiled protobuf runtime files in dev/protos/*.js (firestore_v1, firestore_admin_v1, firestore_v1beta1) with dynamic forwarding exports directly to @google-cloud/firestore-api/build/protos/protos, removing 76,572 lines of static JavaScript.
  • Getter Variable Caching: Applies local variable caching around lazy getters in dev/src/index.ts to ensure referential equality (===) and avoid redundant module require and Object.assign execution on repeated accesses.
  • Deprecation Guidance: Adds explicit JSDoc @deprecated annotations directing consumers to import @google-cloud/firestore-api directly instead of relying on re-exported client properties (Firestore.v1).
  • Build Script Cleanup: Removes legacy OwlBot configuration (owlbot.py, .OwlBot.yaml) and proto compilation scripts (dev/protos/update.sh).

Why Local Types Remain in This Commit

Historically, dev/protos/update.sh compiled static protobuf TypeScript interfaces (firestore_v1_proto_api.d.ts) using custom post-processing: passing --force-enum-string to force protobuf enums into string literal unions ('ASCENDING' | 'DESCENDING'), and executing a Perl regex to replace 64-bit integer Long references with string. Modern GAPIC packages generate standard numeric enums and number | Long.

In this initial pull request, we intentionally retain firestore_v1_proto_api.d.ts while delegating .js runtime files to @google-cloud/firestore-api. This is done specifically in PR #1 to separate the mechanical work of separating the library dependency from the deeper call-site refactoring required to transition from string literals to native GAPIC enums. Once the entire stacked series merges, the final state will be complete reliance on @google-cloud/firestore-api as our single source of truth for all types and runtime models.

Internal: b/531788771


📚 Stack Navigation Index

  1. Layer 1 (Base Disentanglement & Runtime Forwarding): feat(firestore): decouple handwritten sdk wrapper from embedded gapic clients #8928
  2. Layer 2 (Complete Decoupling & Dead Code Cleanup): feat(firestore)!: complete gapic decoupling, adopt subpath imports, and remove legacy proto code (#9074) #9074
  3. Layer 3 (Automated Presubmit Bundle Size Guard): chore(firestore): add automated presubmit serverless bundle size regression guard (#9075) #9075
  4. Layer 4 (Call-Site Modernization & Eliminate Local Protos): refactor(firestore): modernize internal proto call sites and eliminate local declarations (#9076) #9076

@quirogas quirogas self-assigned this Jul 21, 2026
@product-auto-label product-auto-label Bot added the api: firestore Issues related to the Firestore 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 removes auto-generated configuration and proto files, transitioning the Firestore library to depend on the external @google-cloud/firestore-api package. Imports and lazy-loading getters for v1 and v1beta1 are updated accordingly. The review feedback highlights opportunities to optimize performance and code cleanliness: first, by directly requiring @google-cloud/firestore-api in the client factory to avoid repeatedly triggering lazy getters; and second, by caching the loaded modules in the lazy getters for v1 and v1beta1 to prevent redundant module loading and property copying on multiple accesses.

Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/dev/src/index.ts
@quirogas
quirogas marked this pull request as ready for review July 23, 2026 18:05
@quirogas
quirogas requested a review from a team as a code owner July 23, 2026 18:05
Comment thread handwritten/firestore/dev/src/index.ts Outdated
Comment thread handwritten/firestore/dev/src/index.ts Outdated
Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/dev/src/index.ts Outdated
Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/dev/src/index.ts
Comment thread handwritten/firestore/owlbot.py

logging.basicConfig(level=logging.DEBUG)

staging = Path("owl-bot-staging")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We no longer need to copy the gapic files into dev, as they are now live in their own separate library: https://www.npmjs.com/package/@google-cloud/firestore-api.

Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/dev/src/index.ts Outdated
Comment thread handwritten/firestore/dev/src/index.ts
@quirogas
quirogas requested a review from MarkDuckworth July 28, 2026 22:36
@quirogas
quirogas enabled auto-merge (squash) July 29, 2026 23:03
Comment thread handwritten/firestore/dev/src/index.ts Outdated
Comment thread handwritten/firestore/types/firestore.d.ts Outdated
Comment thread handwritten/firestore/owlbot.py
Comment thread handwritten/firestore/owlbot.py
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 3, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 3, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 3, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 3, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
@quirogas
quirogas requested a review from a team as a code owner August 4, 2026 00:05
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
@quirogas
quirogas force-pushed the feat/disentangle-firestore-handwritten branch from a1fc42e to f995b89 Compare August 4, 2026 00:05
…eslintrc (googleapis#8928)

- Update typescript import namespace in bin/linter.mjs (Option 2) to fix ts.sys undefined error
- Execute ESLint and tsc via child process inside target package directory using package local compilers when available
- Update handwritten/firestore/.eslintrc.json to extend root gts config instead of local node_modules
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
@quirogas
quirogas force-pushed the feat/disentangle-firestore-handwritten branch from f995b89 to a833777 Compare August 4, 2026 00:24
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
@quirogas
quirogas disabled auto-merge August 4, 2026 08:06
@quirogas quirogas changed the title feat(firestore): split GAPIC from the firestore handwritten package feat(firestore): decouple handwritten sdk wrapper from embedded gapic clients Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
…e local declarations (googleapis#8928)

- Remove dev/protos/firestore_v1_proto_api.* and dev/protos/v1.json to transition @google-cloud/firestore-api into our automated Single Source of Truth for TypeScript declarations
- Extract custom offline bundle persistence interface definitions into standalone dev/src/bundle-proto.* modules
- Update query operator dictionaries (directionOperators, comparisonOperators) and internal comparators to consume native GAPIC enum objects and 64-bit Long structures
- Verify 100% clean compilation and passing unit test suites across watch, partition-query, aggregate-query, and transaction operations
quirogas added a commit to quirogas/google-cloud-node that referenced this pull request Aug 4, 2026
…onfiguration file mappings (googleapis#8928)

- Remove wildcard asterisk export entries (./v1/*, ./protos/*, ./build/*) to prevent external reliance on private implementation scripts
- Add explicit named subpath export mappings for firestore_client_config.json and protos.json to ensure zero breaking changes across internal wrapper consumers
- Verify 100% passing test execution across all client and admin service operations
quirogas added a commit that referenced this pull request Aug 4, 2026
…cy, and discontinue v1beta1 (#9073)

Parallel architectural update to `@google-cloud/firestore-api`
supporting the handwritten Firestore SDK disentanglement (#8928).

### Summary of Changes
- **Runtime `long` Dependency**: Moves `"long"` from `devDependencies`
to runtime `"dependencies"`. Generated declaration files (`protos.d.ts`)
explicitly import `long`. In environments using strict package managers
with node_modules isolation (such as `pnpm`), omitting `long` from
runtime dependencies causes TypeScript compilation to fail with `error
TS2307: Cannot find module 'long'` (per structural context in
`googleapis/nodejs-firestore#2322`).
- **Subpath Exports**: Configures conditional subpath exports (`./v1`,
`./client_v1`, `./admin_v1`, `./protos`, and configuration files) with
the `"types"` condition placed before `"default"`. This ensures
declaration files resolve correctly for consumers using modern
TypeScript module resolution (`"moduleResolution": "nodenext"`).
- **Discontinue `v1beta1`**: Removed `v1beta1` from `librarian.yaml` and
regenerated the library via `librarian` to stop generating beta client
code.

Internal: b/531788771
@quirogas
quirogas requested a review from MarkDuckworth August 5, 2026 01:24

@MarkDuckworth MarkDuckworth 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.

Looks good in context of the stacked PRs

@quirogas quirogas added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Aug 6, 2026
@quirogas

quirogas commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Labeling as "do not merge" to make sure we merge all stacked prs before merging this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the Firestore API. do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants